Overview
The Unbound Security AI Gateway provides a RESTful API that allows you to integrate AI capabilities into your applications while maintaining enterprise-grade security, cost control, and compliance. The API is compatible with OpenAI’s Chat Completions API format, making it easy to migrate existing integrations.
Base URL
All API requests should be made to:
https://api.getunbound.ai/v1
Authentication
The Unbound API uses Bearer token authentication. Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Your API key can be found in your Unbound application dashboard under the Overview tab.
Chat Completions
Create a completion for the provided chat messages.
Endpoint
POST /v1/chat/completions
| Header | Type | Required | Description |
|---|
Authorization | string | Yes | Bearer token with your API key |
Content-Type | string | Yes | Must be application/json |
Request Body
| Parameter | Type | Required | Description |
|---|
model | string | Yes | The model to use for completion |
messages | array | Yes | Array of message objects |
max_tokens | integer | No | Maximum tokens to generate (default: 1000) |
temperature | number | No | Sampling temperature (0.0 to 2.0, default: 1.0) |
stream | boolean | No | Whether to stream the response (default: false) |
Message Object
| Parameter | Type | Required | Description |
|---|
role | string | Yes | Role of the message sender (user, assistant, system) |
content | string | Yes | Content of the message |
Example Request
curl -X POST 'https://api.getunbound.ai/v1/chat/completions' \
-H "Authorization: Bearer 4922c*****cd9b9" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Help me plan meals for the week."
}
]
}'
Example Response
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here's a balanced meal plan for the week:\n\n**Monday:**\n- Breakfast: Oatmeal with berries and nuts\n- Lunch: Grilled chicken salad\n- Dinner: Salmon with quinoa and vegetables\n\n**Tuesday:**\n- Breakfast: Greek yogurt with granola\n- Lunch: Turkey and avocado wrap\n- Dinner: Pasta with marinara sauce and side salad\n\n**Wednesday:**\n- Breakfast: Scrambled eggs with toast\n- Lunch: Quinoa bowl with chickpeas and vegetables\n- Dinner: Grilled chicken with sweet potato and broccoli\n\n**Thursday:**\n- Breakfast: Smoothie bowl with fruits\n- Lunch: Lentil soup with whole grain bread\n- Dinner: Baked cod with rice and green beans\n\n**Friday:**\n- Breakfast: Pancakes with maple syrup\n- Lunch: Chicken Caesar salad\n- Dinner: Pizza night with vegetable toppings\n\n**Saturday:**\n- Breakfast: French toast with berries\n- Lunch: Grilled cheese and tomato soup\n- Dinner: Steak with roasted vegetables\n\n**Sunday:**\n- Breakfast: Waffles with fruit\n- Lunch: Leftovers or simple sandwich\n- Dinner: Roast chicken with mashed potatoes and gravy\n\nThis plan provides variety, balanced nutrition, and includes both healthy options and some comfort foods for the weekend."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 245,
"total_tokens": 260
}
}
List Models
Retrieve a list of available models for your application.
Endpoint
| Header | Type | Required | Description |
|---|
Authorization | string | Yes | Bearer token with your API key |
Example Request
curl -X GET 'https://api.getunbound.ai/models' \
-H "Authorization: Bearer 4922c*****cd9b9"
Example Response
{
"anthropic/claude-opus": {
"maxTokens": "32000",
"contextWindow": "200000",
"cacheReadPrice": "1.500000",
"supportsImages": true,
"cacheWritePrice": "18.750000",
"inputTokenPrice": "15.000000",
"outputTokenPrice": "75.000000",
"supportsWebSearch": true,
"supportsComputerUse": true,
"supportsPromptCaching": true,
"supportsExtendedThinking": true
},
}
Model availability depends on your Unbound application configuration and routing rules. Use the /models endpoint to get the current list of available models for your application.
Advanced Examples
Multi-turn Conversation
curl -X POST 'https://api.getunbound.ai/v1/chat/completions' \
-H "Authorization: Bearer 4922c*****cd9b9" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful coding assistant."
},
{
"role": "user",
"content": "How do I create a REST API in Python?"
},
{
"role": "assistant",
"content": "I can help you create a REST API in Python using Flask or FastAPI. Which framework would you prefer?"
},
{
"role": "user",
"content": "Let's use FastAPI"
}
],
"max_tokens": 1000,
"temperature": 0.7
}'
Streaming Response
curl -X POST 'https://api.getunbound.ai/v1/chat/completions' \
-H "Authorization: Bearer 4922c*****cd9b9" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Write a Python function to calculate fibonacci numbers"
}
],
"stream": true
}'