curl / HTTP

All ModelBridge endpoints follow the OpenAI REST API format. You can use curl, httpie, or any HTTP client to interact with the API directly.

Base URL

Base URL

https://api.modelbridge.dev/v1

All requests require the Authorization header with your API key:

Authorization header

Authorization: Bearer mb_live_your_key_here

Chat completions

POST
/v1/chat/completions
curl https://api.modelbridge.dev/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in one paragraph."}
    ]
  }'

Streaming

Add "stream": true to get Server-Sent Events (SSE):

Streaming request

curl https://api.modelbridge.dev/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-5.4",
    "messages": [
      {"role": "user", "content": "Write a short poem about code."}
    ],
    "stream": true
  }'

Each chunk is prefixed with data: and contains a JSON object. The stream ends with data: [DONE].

Example chunk:

Example chunk

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

Tool calling

Tool calling

curl https://api.modelbridge.dev/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "user", "content": "What is the weather in Tokyo?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get the current weather for a location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {
                "type": "string",
                "description": "City and state"
              }
            },
            "required": ["location"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'

List models

GET
/v1/models
curl https://api.modelbridge.dev/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY"

Multi-turn conversation

Send the full conversation history in the messages array:

Multi-turn conversation

curl https://api.modelbridge.dev/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {"role": "system", "content": "You are a helpful coding assistant."},
      {"role": "user", "content": "Write a Python function to reverse a string."},
      {"role": "assistant", "content": "def reverse_string(s):\n    return s[::-1]"},
      {"role": "user", "content": "Now make it handle Unicode properly."}
    ]
  }'

Request format reference

FieldTypeRequiredDescription
modelstringYesModel ID
messagesarrayYesConversation messages
streambooleanNoEnable SSE streaming
temperaturefloatNo0.0-2.0, controls randomness
max_tokensintegerNoMax response tokens
toolsarrayNoTool/function definitions
tool_choicestringNoauto, none, required
top_pfloatNoNucleus sampling threshold
stopstring/arrayNoStop sequences

Was this page helpful?