Router One
Router One
Chat

Create Message

创建一个 Claude / Anthropic Messages 兼容请求。适用于 Claude Code 等按 Messages API 形态调用的客户端,支持流式和非流式响应。

POST
/v1/messages
AuthorizationBearer <token>

使用 API Key 进行认证。在 Router One 控制台获取你的 API Key,格式为 sk-xxx

In: header

modelstring

模型 ID。设为 auto 时由 Router One 自动选择,也可以指定具体模型。

messages

Claude / Anthropic Messages 格式的对话消息。

Items1 <= items
system?string

可选系统提示词。

max_tokensinteger

最大输出 token 数。

Range1 <= value
stream?boolean

是否启用流式响应。

Defaultfalse
temperature?number

采样温度,范围 0-2。

Default1
Range0 <= value <= 2

Response Body

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": "你好"      }    ]  }'
{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-20250514",
  "content": [
    {
      "type": "text",
      "text": "你好!有什么我可以帮你的吗?"
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 9,
    "output_tokens": 12
  }
}
{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
{
  "error": {
    "message": "Insufficient balance",
    "type": "billing_error",
    "code": "insufficient_balance"
  }
}
{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}
{
  "error": {
    "message": "string",
    "type": "string",
    "code": "string"
  }
}