跳轉到主要內容
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