Skip to main content

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
Get your API key at gateway.getunbound.ai/connect.

Chat Completions

Create a completion for the provided chat messages.

Endpoint

POST /v1/chat/completions

Request Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token with your API key
Content-TypestringYesMust be application/json

Request Body

ParameterTypeRequiredDescription
modelstringYesThe model to use for completion
messagesarrayYesArray of message objects
max_tokensintegerNoMaximum tokens to generate (default: 1000)
temperaturenumberNoSampling temperature (0.0 to 2.0, default: 1.0)
streambooleanNoWhether to stream the response (default: false)

Message Object

ParameterTypeRequiredDescription
rolestringYesRole of the message sender (user, assistant, system)
contentstringYesContent of the message

Example Request

curl -X POST 'https://api.getunbound.ai/v1/chat/completions' \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4-20250514",
    "messages": [
      {
        "role": "user",
        "content": "Help me plan meals for the week."
      }
    ]
  }'

Example Response

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "anthropic/claude-sonnet-4-20250514",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here's a balanced meal plan for the week..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 245,
    "total_tokens": 260
  }
}

Multi-turn Conversation

curl -X POST 'https://api.getunbound.ai/v1/chat/completions' \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4-20250514",
    "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 YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4-20250514",
    "messages": [
      {
        "role": "user",
        "content": "Write a Python function to calculate fibonacci numbers"
      }
    ],
    "stream": true
  }'