跳转到主要内容
POST
/
chat
/
completions
curl --request POST \ --url https://api.orcarouter.ai/v1/chat/completions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data ' { "model": "openai/gpt-4o-mini", "messages": [ { "role": "user", "content": "Say hi in one word." } ], "max_tokens": 10 } '
{
  "id": "<string>",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "content": "<string>",
        "name": "<string>",
        "tool_calls": [
          {
            "id": "<string>",
            "function": {
              "name": "<string>",
              "arguments": "<string>"
            }
          }
        ],
        "tool_call_id": "<string>"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

授权

Authorization
string
header
必填

OrcaRouter API 密钥形如 sk-orca-...。请在 Authorization: Bearer sk-orca-... 头中传入。

请求体

application/json
model
string
必填

模型 ID。支持三种形式:

  • 带服务商前缀(默认):openai/gpt-4o-minianthropic/claude-sonnet-4.6google/gemini-2.5-flash
  • 裸名别名:gpt-4o-mini(当存在裸名别名时)
  • 命名路由器:orcarouter/{name}(在请求时解析为模型;orcarouter/auto 在每个账户注册时自动创建,挑选最便宜的在线 chat 模型)
示例:

"gpt-4o"

"openai/gpt-4o"

"orcarouter/auto"

messages
object[]
必填
stream
boolean

为 true 时响应以 server-sent events 形式流式返回。

stream_options
object

仅在 stream: true 时生效。

tools
object[]
tool_choice
可用选项:
auto,
none,
required
parallel_tool_calls
boolean
默认值:true
response_format
Text (default) · object
temperature
number
必填范围: 0 <= x <= 2
top_p
number
必填范围: 0 <= x <= 1
max_tokens
integer
必填范围: x >= 1
max_completion_tokens
integer

推理模型优先用此字段(而非 max_tokens)。

n
integer
默认值:1
必填范围: x >= 1
stop
seed
integer

用于确定性采样。

logprobs
boolean
top_logprobs
integer
必填范围: 0 <= x <= 20
presence_penalty
number
必填范围: -2 <= x <= 2
frequency_penalty
number
必填范围: -2 <= x <= 2
logit_bias
object
user
string
reasoning_effort
enum<string>

供 OpenAI 推理模型使用(o1o3*o4*gpt-5*-pro 等)。Anthropic Claude 改用 thinking 字段;Gemini 使用 服务商特定配置。

可用选项:
low,
medium,
high
web_search_options
object

在 Chat Completions 请求上启用联网搜索。Responses API 改用 tools: [{"type": "web_search"}]。OpenAI 搜索预览 模型、接受现代 web_search 工具的 OpenAI 模型,以及 Anthropic 模型(翻译为 Anthropic 原生 web_search 服务端工具)都会识别它。

web_search_options 不够表达时,可使用的自由形式原始 载荷,会被转发到上游的 web-search 工具。大多数用户应优先 使用 web_search_options

extra_body
object

OrcaRouter 特有的请求扩展。请放在 chat completion 请求 体的顶层 extra_body 键下。

响应

成功完成。流式响应使用 SSE(text/event-stream)。

id
string
object
enum<string>
可用选项:
chat.completion
created
integer
model
string
choices
object[]
usage
object