Skip to content

Claude Messages ​

Call Claude models with the native Anthropic Messages format.

http
POST /v1/messages

The Claude Messages endpoint keeps Anthropic’s native request shape, which suits migrations that already use a Claude SDK or native prompt structure. Traffic is routed in Claude relay format and dispatched to the matching upstream by channel.

The default example model is .

Available models ​

ModelDescription
Latest Claude Opus 5 series
Claude Sonnet 5 series
Claude Opus 4.7
Claude Opus 4.6 thinking mode
Claude Opus 4.5
Claude Sonnet 4.6
Claude Haiku 4.5 lightweight model
Claude 5 series

Headers ​

NameTypeRequiredDescription
stringYesRequest authentication. Use a Bearer Token, for example:
stringNoNative Claude auth header; can replace , for example:
stringNoNative Claude version header; use with , for example:
stringYesRequest content type; must be

Request body ​

NameTypeRequiredDescription
stringYesClaude model name; default example ; see Available models above
integerYesMaximum output tokens. Required by the official API; generation stops when this count is reached ( is )
arrayYesConversation messages; roles must alternate between and
string | arrayNoSystem prompt. Claude does not use a role message—pass it via this field; when an array is passed, items are content blocks and may include
booleanNoWhether to enable SSE streaming; default
numberNoSampling temperature, range –, default ; prefer tuning only one of or
numberNoNucleus sampling; prefer not adjusting together with
integerNoTop-K sampling; sample only from the K highest-probability tokens
arrayNoCustom stop sequences; generation stops when any sequence is produced; the sequence is not included in the output
arrayNoTool definitions
objectNoControls tool selection strategy
objectNoExtended thinking config; only for models with thinking capability
objectNoRequest metadata
stringNoService capacity tier: (default) /
objectNoStructured output config; can be a JSON Schema
objectNoContext management config; array defines edit policies
arrayNoMCP connector server list
stringNoContainer ID; can reuse a code-execution container returned by a previous response
stringNoInference region restriction, e.g. means run inference in the US only

messages item ​

NameTypeRequiredDescription
stringYesMessage role: or
string | arrayYesPlain string, or content block array. Common types: , ( supports / ), , , ,

tools item ​

NameTypeRequiredDescription
stringYesTool name
stringNoTool description to help the model decide when to call it
objectYesJSON Schema for tool parameters, typically

tool_choice ​

NameTypeRequiredDescription
stringYes (default; model decides) / (must call a tool) / (force a specific tool) / (disallow tools)
stringConditionalWhen is , the tool name to force
booleanNoSet to to disallow calling multiple tools in parallel in one reply

thinking ​

NameTypeRequiredDescription
stringYes to turn thinking on, to turn it off
integerNoThinking token budget; must be less than

metadata ​

NameTypeRequiredDescription
stringNoStable end-user identifier (prefer an irreversible ID or hash) for abuse detection

Request example ​

Basic request ​

bash
curl -X POST https://octopusx.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "system": "You are a rigorous technical advisor.",
    "messages": [
      {
        "role": "user",
        "content": "Explain why an API gateway needs rate limiting."
      }
    ]
  }'

Multimodal input ​

bash
curl -X POST https://octopusx.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "url",
              "url": "https://example.com/diagram.png"
            }
          },
          {
            "type": "text",
            "text": "Based on this architecture diagram, explain which layer rate limiting should sit on."
          }
        ]
      }
    ]
  }'

Tool calling ​

bash
curl -X POST https://octopusx.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Get the weather for a given city",
        "input_schema": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
      }
    ],
    "tool_choice": { "type": "auto" },
    "messages": [
      {
        "role": "user",
        "content": "Check the weather in Shanghai today."
      }
    ]
  }'

Response example ​

200 - Non-streaming ​

json
{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-6",
  "content": [
    {
      "type": "text",
      "text": "Rate limiting at an API gateway protects upstream services from traffic spikes, prevents resource exhaustion, and helps deliver stable quality of service across users."
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 32,
    "output_tokens": 45
  }
}

200 - Streaming ​

Streaming responses use text/event-stream. Common event types include , , , , , and .

text
event: message_start
data: {"type":"message_start","message":{"id":"msg_abc123","type":"message","role":"assistant","model":"claude-sonnet-4-6","content":[],"stop_reason":null,"usage":{"input_tokens":32,"output_tokens":0}}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Rate limiting"}}

event: message_stop
data: {"type":"message_stop"}

Response fields ​

NameTypeDescription
stringMessage ID
stringObject type; always
stringMessage role; always
stringModel that generated the response
arrayContent blocks; common blocks include (e.g. ) and
stringStop reason, e.g. , , ,
objectToken usage; includes ,