POST
https://octopusx.ai
/
v1
/
messages
curl -X POST https://octopusx.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "system": "You are a rigorous technical advisor.",
    "messages": [
      {
        "role": "user",
        "content": "Explain why an API gateway needs rate limiting."
      }
    ]
  }'
{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-20250514",
  "content": [
    {
      "type": "text",
      "text": "API gateway rate limiting can protect upstream services, prevent sudden traffic from exhausting resources, and provide stable service quality for different users."
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 32,
    "output_tokens": 45
  }
}

Claude Messages API

The Claude Messages API preserves Anthropic’s native request structure and is suitable for migrating existing Claude SDK-based services or services using native prompt structures. Requests will be routed into the Claude relay format and dispatched to the corresponding upstream based on the channel.

Authentication

Authorization: Bearer YOUR_API_KEY
You can also use Claude native request headers:
x-api-key: YOUR_API_KEY
anthropic-version: 2023-06-01

Request Body

model
string
required
Claude model name.
messages
array<object>
required
Array of conversation messages. In Claude’s native format, message roles are typically user or assistant.
system
string | array<object>
System prompt. Claude does not use system role messages; instead, system instructions are passed through this field.
max_tokens
integer
Maximum number of output tokens. Most Claude requests should pass this explicitly.
stream
boolean
Whether to enable SSE streaming output.
temperature
number
Sampling temperature.
top_p
number
Top-p sampling parameter.
top_k
integer
Top-K sampling parameter.
stop_sequences
array<string>
Stop sequences.
tools
array<object>
Claude tool list, typically including name, description, and input_schema.
tool_choice
object
Controls the tool selection strategy, for example { "type": "tool", "name": "get_weather" }.
thinking
object
Extended thinking configuration, for example { "type": "enabled", "budget_tokens": 10000 }.
metadata
object
Business-side metadata, such as user_id.

Request Example

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

Multimodal Input

curl -X POST https://octopusx.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "image",
            "source": {
              "type": "url",
              "url": "https://.../architecture.png"
            }
          },
          { "type": "text", "text": "What risk points are there in this architecture diagram?" }
        ]
      }
    ]
  }'

Tool Calling

curl -X POST https://octopusx.ai/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [
      { "role": "user", "content": "Is Shanghai suitable for cycling today?" }
    ],
    "tools": [
      {
        "name": "get_weather",
        "description": "Query city weather",
        "input_schema": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
      }
    ]
  }'

Response Example

{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-20250514",
  "content": [
    {
      "type": "text",
      "text": "API gateway rate limiting can protect upstream services, prevent sudden traffic from exhausting resources, and provide stable service quality for different users."
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 32,
    "output_tokens": 45
  }
}