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

创建聊天补全

创建一个聊天补全请求:OpenAI Chat Completions 兼容端点,一个 base URL 接入 40+ 模型,支持流式和非流式响应,`model: auto` 走智能路由。 设置 `model` 为 `auto` 时,Router One 会按当前网关策略从服务端候选集中选择。

POST
/v1/chat/completions
AuthorizationBearer <token>

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

In: header

modelstring

模型 ID。设置为 auto 时按网关策略使用服务端候选集,也可指定具体模型如 openai/gpt-5.5anthropic/claude-sonnet-5 等(模型 ID 以目录为准)。

messages

聊天消息列表,按时间顺序排列。

Items1 <= items
stream?boolean

是否启用流式响应。启用后返回 SSE 事件流。

Defaultfalse
temperature?number

采样温度,范围 0-2。较高的值(如 0.8)使输出更随机,较低的值(如 0.2)使输出更确定。

Default1
Range0 <= value <= 2
max_tokens?integer

生成的最大 token 数量。

Range1 <= value
top_p?number

核采样参数。模型考虑概率质量前 top_p 的 token 结果。

Default1
Range0 <= value <= 1
reasoning_effort?string

推理强度提示,如 lowmediumhigh。按原值转发给模型,Router One 不校验、不改写该值。支持程度因模型而异:没有该控制项的模型会忽略它或返回 400 invalid_request,使用前先查该模型的目录页。

stream_options?

流式响应选项。仅在 stream: true 时有效。

tools?

可供模型调用的工具(函数)声明。支持程度因模型而异,使用前先查该模型的目录页。

tool_choice?string|

控制模型如何选择工具。auto 由模型自行决定,none 关闭工具调用,required 强制调用某个工具,传对象并指定函数名则强制调用该函数。

response_format?

转发给模型的输出格式提示。json_object 要求模型回复 JSON;json_schema 额外附带一份 JSON Schema。Router One 只校验请求形状——type 为 json_schema 而缺少 json_schema.namejson_schema.schema 时,在到达模型前即返回 400 invalid_request——不校验、不修复模型输出。Schema 是否被强制执行取决于模型,支持程度因模型而异,请用目标模型实测。详见结构化输出指南

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://api.router.one/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "auto",    "messages": [      {        "role": "user",        "content": "你好"      }    ]  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "auto",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!有什么我可以帮你的吗?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}
{
  "error": {
    "message": "invalid api key",
    "type": "authentication_error",
    "code": "AUTH_INVALID_API_KEY",
    "request_id": "290dd478f91d8aec68f7535e871376eb"
  }
}

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

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