跳到主要内容
Router One
Router One
对话生成

创建消息(Messages)

创建 Claude / Anthropic Messages 兼容请求(Claude Code 使用的形态),供 Claude 与 DeepSeek V4 使用,支持流式与非流式。其他模型请走 /v1/chat/completions。不属于这两个系列的模型同样会在调用任何模型之前被拒绝:400 invalid_request_error,消息为 model '<id>' must be called via /v1/chat/completions。错误体采用 Anthropic 信封 {"type":"error","error":{type,message,code},"request_id"},不是其他端点的 OpenAI {"error":{…}} 形状。

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

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": "anthropic/claude-sonnet-5",
  "content": [
    {
      "type": "text",
      "text": "你好!有什么我可以帮你的吗?"
    }
  ],
  "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"
}