Skip to content
Skip to content
Router One
Chat

Create Message

Create a Claude / Anthropic Messages compatible request — the shape Claude Code uses — for currently listed Claude-family models and DeepSeek ids. Streaming and non-streaming responses are supported; call other chat models via /v1/chat/completions. A model sent to an unsupported endpoint is rejected before any model runs: 400 invalid_request_error, model '<id>' must be called via /v1/chat/completions. Error bodies use the Anthropic envelope {"type":"error","error":{type,message,code}} rather than the OpenAI {"error":{…}} shape used by the other endpoints; errors the gateway returns itself (for example 401 and 429) also carry a top-level request_id, and every response carries an X-Request-ID header.

Function tools are forwarded as sent (tools with input_schema, tool_choice; tool_use / tool_result blocks round-trip), except that for Claude Opus 5.5 (claude-opus-5-5 or anthropic/claude-opus-5.5) a tool_choice of any or tool is sent as auto, so that model may answer in text instead of calling the tool; whether a model accepts a forced tool_choice is up to its vendor (see Anthropic's tool-use docs, checked 2026-10-09). Anthropic server tools: web_search and code_execution — including its bash_* / text_editor_* sub-tools and container reuse across turns — are accepted and metered at the model's posted token rates (container time is not passed through per call); web_fetch, mcp_toolset and mcp_servers are rejected before any model runs with 400 invalid_request_error.

A long stream: false call is held open (as of 2026-10-09): after about 25 seconds the gateway commits HTTP 200 and writes JSON leading whitespace until the Message is ready, so a failure after that point arrives as HTTP 200 with the error envelope above — check type before reading content; use stream: true for generations that take minutes.

Full reference for every endpoint: Markdown · OpenAPI 3.1 JSON

POST
/v1/messages
AuthorizationBearer <token>

Authenticate with your API Key. Get your API Key in the Router One console; the format is sk-xxx.

In: header

modelstring

Model ID. Set to auto for Router One routing, or specify a concrete model. Most official bare names (for example gpt-5.5 or claude-sonnet-5) are accepted as aliases of the catalog id; copy the catalog id from /models to be safe.

messages

Conversation messages in the Claude / Anthropic Messages format.

Items1 <= items
system?string

Optional system prompt.

max_tokensinteger

Maximum number of output tokens.

Range1 <= value
stream?boolean

Whether to enable streaming response.

Defaultfalse
temperature?number

Sampling temperature, range 0-2.

Default1
Range0 <= value <= 2
tools?

Anthropic tool declarations, forwarded as sent. Function tools carry input_schema; the server tools web_search and code_execution are accepted, while web_fetch and mcp_toolset are rejected with 400 invalid_request_error.

tool_choice?object

How the model may use the declared tools (auto, any, tool, none), forwarded as sent — except for Claude Opus 5.5 (claude-opus-5-5 or anthropic/claude-opus-5.5), for which any and tool are sent as auto, so check stop_reason and the content block types; whether a model accepts a forced choice is up to its vendor.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.router.one/v1/messages" \  -H "Content-Type: application/json" \  -d '{    "model": "auto",    "max_tokens": 1024,    "messages": [      {        "role": "user",        "content": "Hello"      }    ]  }'
{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-5",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you?"
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 9,
    "output_tokens": 12
  }
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "model 'openai/gpt-5.5' must be called via /v1/chat/completions",
    "code": "INVALID_REQUEST"
  }
}
{
  "type": "error",
  "error": {
    "type": "authentication_error",
    "message": "invalid api key",
    "code": "AUTH_INVALID_API_KEY"
  },
  "request_id": "86bc1f64e4bcdfc3cc516e51cc419418"
}

{
  "type": "error",
  "error": {
    "type": "billing_error",
    "message": "insufficient balance: top up at https://router.one/deposit"
  }
}

{
  "type": "error",
  "error": {
    "type": "rate_limit_error",
    "message": "rate limit exceeded",
    "code": "RATE_LIMIT_EXCEEDED"
  },
  "request_id": "86bc1f64e4bcdfc3cc516e51cc419418"
}
{
  "type": "error",
  "error": {
    "type": "api_error",
    "message": "internal error",
    "code": "INTERNAL_ERROR"
  },
  "request_id": "86bc1f64e4bcdfc3cc516e51cc419418"
}