跳转到主要内容
通过 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 都会按内置工具计费——参阅 运维 / 计费与用量

跨服务商支持

联网搜索能触达每一家提供该能力的服务商;只是入口不同:
服务商联网搜索入口
OpenAISearch-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 接地工具。
DeepSeekDeepSeek 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 按内置工具调用计费,单价梯度 不同——参阅运维 / 计费与用量 查看明细。