跳轉到主要內容
通過 OrcaRouter 聯網搜索有兩條路徑:
  1. Search-preview 模型 — 直接在 /v1/chat/completions 上調用一個搜索變體模型
  2. 常規模型 + 工具/選項 — 傳 web_search_options(Chat)或 tools: [{"type": "web_search"}](Responses)

Search-preview 模型(OpenAI)

OpenAI 為多個模型發布了 search-preview 變體——例如 openai/gpt-4o-search-previewopenai/gpt-5-search-api。 把其中之一設為 /v1/chat/completionsmodel,上游會在服務端 完成搜索。 調用 /v1/models 獲取實時目錄。

web_search_options(Chat Completions)

curl https://api.orcarouter.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-orca-..." \
  -d '{
    "model": "openai/gpt-4o-search-preview",
    "messages": [{"role": "user", "content": "What changed in OpenAI pricing this week?"}],
    "web_search_options": {"search_context_size": "medium"}
  }'
search_context_sizelow / medium / high。控制搜索深度 (web_search 的每次調用價格與深度無關)。

Tools(Responses API)

/v1/responses 接受 tools: [{"type": "web_search"}],對 OpenAI 模型 和任意 Grok 模型都有效——xAI 的 Agent Tools 接口住在同一個端點上。
# OpenAI
curl https://api.orcarouter.ai/v1/responses \
  -H "Authorization: Bearer sk-orca-..." \
  -d '{
    "model": "openai/gpt-5",
    "input": "What changed in OpenAI pricing this week?",
    "tools": [{"type": "web_search"}]
  }'

# Grok(xAI Agent Tools)
curl https://api.orcarouter.ai/v1/responses \
  -H "Authorization: Bearer sk-orca-..." \
  -d '{
    "model": "grok/grok-4-fast-reasoning",
    "input": "What changed in xAI pricing this week?",
    "tools": [{"type": "web_search"}]
  }'
上游每發出一次 web_search_call 都會按內置工具計費——參閱 運維 / 計費與用量

跨服務商支持

聯網搜索能觸達每一家提供該能力的服務商;只是入口不同:
服務商聯網搜索入口
OpenAI?Search-preview 模型,或在 /v1/responsesweb_search 工具
xAI Grok?/v1/responses 配合任意 Grok 模型傳 tools: [{"type": "web_search"}] —— 即 xAI 的 Agent Tools API。(xAI 已于 2026-01-12 棄用 chat completions 上的舊 search_parameters;舊的 *-search 模型名變體不再可用。)
Anthropic?在 Chat Completions 請求上傳 web_search_options —— 會被翻譯為 Anthropic 原生的 web_search 服務端工具。search_context_size(low/medium/high)映射到 max_usesuser_location.approximate 映射到 Anthropic 的 user_location
Gemini?傳一個名為 googleSearch 的函數工具(見下文)—— 會被翻譯為 Gemini 原生的 GoogleSearch 接地工具。
DeepSeek?DeepSeek API 不提供聯網搜索。

Gemini 通過 googleSearch 接地

對于 Gemini 模型,OrcaRouter 的翻譯層會識別魔法函數名 googleSearch,并把它轉換為 Gemini 原生的 GoogleSearch 接地工具。 像傳任何其他 OpenAI 風格函數工具那樣傳它即可:
curl https://api.orcarouter.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-orca-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-2.5-flash",
    "messages": [{"role":"user","content":"What changed in Gemini pricing this week?"}],
    "tools": [{"type":"function","function":{"name":"googleSearch"}}]
  }'
Gemini 返回的接地元數據(webSearchQueries 等)會被網關捕獲用于計費, 并通過標準 chat-completion 字段透出。另外兩個魔法函數名走同一條 代碼路徑:
  • codeExecution —— 啟用 Gemini 原生代碼執行工具
  • urlContext —— 啟用 Gemini URL 上下文工具

或者直接走原生

如果你已經在用 Gemini 的 /v1beta/ 原生協議,按 Gemini 形態直接傳 googleSearch 即可,無需走魔法名翻譯:
curl "https://api.orcarouter.ai/v1beta/models/google/gemini-2.5-flash:generateContent" \
  -H "Authorization: Bearer sk-orca-..." \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"role":"user","parts":[{"text":"What changed in Gemini pricing this week?"}]}],
    "tools": [{"googleSearch": {}}]
  }'
{"codeExecution": {}}{"urlContext": {}} 在原生路徑上工作方式 相同。參閱原生格式 / Gemini

計費

web_searchweb_search_preview 按內置工具調用計費,單價梯度 不同——參閱運維 / 計費與用量 查看明細。