Web Search Tools in Claude, OpenAI, and Gemini APIs Compared
Compare web search tools in Claude, OpenAI, and Gemini APIs, covering request schemas, domain filters, inline citations, latency, and tool pricing.
- Anthropic provides versioned tools with optional dynamic filtering through code execution to cut context load.
- OpenAI offers hosted web search inside the Responses API alongside search context size and token budget knobs.
- Google grounds Gemini through the google_search tool with search suggestion widgets and inline url_citation spans.
- Billing models diverge sharply between per-query charges for Gemini 3 and token-only or tool-call charges elsewhere.
Architectural Models for Live Search Grounding
Connecting large language models to real-time internet data eliminates stale knowledge cutoffs and mitigates factual hallucinations. Anthropic, OpenAI, and Google each provide built-in server-side tools that retrieve web content, parse pages, and attach citations directly inside model turns. However, each platform organizes the orchestration layer differently. Anthropic embeds web search as an autonomous tool call within the Messages API where the model determines when retrieval is necessary. OpenAI concentrates search capabilities inside the Responses API with specialized execution styles for non-reasoning and reasoning models. Google integrates retrieval into the Interactions API as a native grounding step that surfaces search suggestions alongside grounded answers across all available languages.
| Provider | API Interface | Primary Tool Identifier | Execution Mechanism |
|---|---|---|---|
| Anthropic Claude | Messages API | web_search_20250305, web_search_20260209, web_search_20260318 | Direct server tool execution or dynamic filtering via code execution |
| OpenAI | Responses API | web_search | Non-reasoning lookup, reasoning chain-of-thought search, or deep research |
| Google Gemini | Interactions API | google_search | Automated search query generation, synthesis, and grounding steps |
Execution styles impact latency and context efficiency. Anthropic offers dynamic filtering starting with web_search_20260209 and web_search_20260318 on Claude 4.6 and later models as well as Claude Mythos Preview. Instead of dumping full search extracts directly into prompt context, Claude writes and runs code through code execution to filter search results beforehand, retaining only relevant text. OpenAI categorizes search into three operational paths: fast non-reasoning search for simple queries, agentic search where reasoning models manage multiple queries inside their chain of thought, and deep research for extended investigations that consult numerous sources using gpt-5.5 with reasoning effort set to high or xhigh. Google Gemini coordinates searching through automated planning where the model produces thoughts, executes queries via google_search_call, receives search suggestions via google_search_result, and returns synthesized answers with fine-grained citations.
Tool Request Configuration and Parameter Schemas
Enabling search requires passing provider-specific tool definitions inside the request payload. Each provider exposes controls to govern how aggressively the model searches, how many search queries it may initiate, and how much result context it ingests before finalizing its response. Developers can explore composable tool architectures in /posts/function-and-tool-calling-across-claude-gpt-and-gemini/.
curl https://api.anthropic.com/v1/messages -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d '{"model": "claude-opus-5-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "What is the weather in NYC?"}], "tools": [{"type": "web_search_20250305", "name": "web_search", "max_uses": 5}]}'
curl https://api.openai.com/v1/responses -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{"model": "gpt-6-astra", "tools": [{"type": "web_search", "search_context_size": "low"}], "input": "What movie won best picture in 2025?"}'
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" -H "x-goog-api-key: $GEMINI_API_KEY" -H "Content-Type: application/json" -d '{"model": "gemini-3.8-flash", "input": "Who won the euro 2024?", "tools": [{"type": "google_search"}]}'
The parameters govern iteration depth. Anthropic supports max_uses to place a definitive ceiling on search invocations. Simple factual questions typically consume 1–3 searches, whereas comparative research queries can trigger 10 or more. If Claude exceeds this threshold, the API returns a max_uses_exceeded error code. OpenAI provides search_context_size, which takes low, medium, or high to scale the volume of page content presented to the model. For extended multi-step investigations, OpenAI provides return_token_budget with options default and unlimited, intended for GPT-5+ reasoning models. Gemini handles query generation internally from the user prompt without exposing manual query count caps in the tool object.
Domain Filtering, Localization, and Context Scoping
Enterprise applications often require restricting search boundaries to trusted corporate portals, documentation domains, or specific geographic regions. All three platforms provide mechanisms to govern source domains or localize answers, though the syntax and platform restrictions vary.
- Anthropic domain rules accept either allowed_domains or blocked_domains as bare domain strings with optional paths such as example.com or example.com/blog. Supplying both lists in the same request causes the API to return a 400 error.
- Anthropic localization accepts user_location with type approximate, allowing configurations for city, region, country via ISO 3166-1 alpha-2 codes, and timezone via IANA identifiers. Unsupported country codes trigger a 400 error.
- OpenAI domain filtering in the Responses API uses the filters object, supporting up to 100 allowed_domains or up to 100 blocked_domains without HTTP or HTTPS prefixes, automatically including subdomains.
- OpenAI context scoping lets developers adjust search_context_size between low, medium, and high, while return_token_budget can be set to unlimited alongside background mode for long-running research.
- Anthropic response inclusion on web_search_20260318 allows setting response_inclusion to excluded, which discards intermediate raw search result blocks consumed by completed code execution runs to minimize output token volume.
Platform availability also dictates implementation options. Anthropic web search runs across the Claude API, Claude Platform on AWS, and Microsoft Foundry. On Microsoft Foundry, deployments hosted on Azure only support basic web_search_20250305 without dynamic filtering, whereas Anthropic-hosted deployments support all versions. Google Cloud supports basic web search without dynamic filtering, while Amazon Bedrock does not support web search. OpenAI limits filters and return_token_budget to the Responses API with web_search, whereas legacy Chat Completions integrations must rely on gpt-5-search-api after the deprecation and scheduled shutdown of gpt-4o-search-preview and gpt-4o-mini-search-preview on 2026-07-23.
Citation Schemas, Annotations, and Output Structures
Presenting verifiable sources requires parsing provider citation objects. Each API attaches citation metadata directly to specific character offsets or content blocks in the final completion, ensuring client interfaces can render interactive links. Teams standardizing schema validation can consult /posts/structured-outputs-across-claude-gpt-and-gemini-apis/.
Anthropic returns server_tool_use and web_search_tool_result blocks in the message content. Search results contain url, title, page_age, and encrypted_content. In the final synthesized text block, Claude appends citations with web_search_result_location objects containing url, title, cited_text, and encrypted_index. Usage objects report total server_tool_use requests under the web_search_requests counter, showing exact tool invocations.
OpenAI returns web_search_call output items containing the call identifier, status, and action details. The action is classified as search, open_page, or find_in_page, where search lists the queries executed. The assistant message content contains output_text with an annotations array of url_citation objects specifying start_index, end_index, url, and title. OpenAI policies require inline citations to be clickable in user interfaces. OpenAI also exposes a sources field listing all consulted URLs, including real-time categorical feeds designated as oai-sports, oai-weather, or oai-finance.
Google Gemini represents the grounding lifecycle as distinct steps within the interaction response. The model outputs a thought step, followed by google_search_call containing executed search queries, followed by google_search_result containing search_suggestions HTML snippets. Finally, model_output delivers text containing annotations with url_citation objects. Each citation specifies start_index and end_index offsets alongside title and url, allowing client applications to map exact text slices, such as match scores or event winners, to their original sources.
Pricing Models, Tool Surcharges, and Token Economics
The financial footprint of web search spans both token consumption and per-query tool surcharges. Depending on the provider, developers pay per search execution, per prompt, or purely through context token throughput. Composite expenses can be modeled using /tools/llm-api-cost-calculator/ and /tools/llm-api-pricing/.
- Google Gemini 3 and newer models bill for each search query executed by the model, providing 5,000 free search requests per month across Gemini 3 and newer models, then charging $14 per 1,000 search requests.
- Google Gemini 2.5 and older models, such as Gemini 2.5 Pro (input $1.25, cached input $0.125, output $10) and Gemini 2.5 Flash (input $0.3, cached input $0.03, output $2.5), bill search grounding per prompt rather than per executed query.
- OpenAI assesses a tool call cost for search actions, in addition to standard token rates for models such as GPT-6 Astra (input $10, cached input $1, output $50) or gpt-5.5.
- Anthropic does not charge extra tool surcharges for code execution calls spun up automatically by dynamic filtering, billing standard model tokens on Claude Opus 5.5 (input $4, cached input $0.2, output $20) or Claude Sonnet 5.5 (input $2, cached input $0.2, output $10).
- Anthropic dynamic filtering with web_search_20260209 or later prevents unneeded web content from entering the context window, and setting response_inclusion to excluded on web_search_20260318 eliminates raw search block output tokens.
Context token bloat represents a major operational cost driver. Basic web search without dynamic filtering ingests full page extracts into prompt memory, expanding cached and non-cached token totals. For high-volume workloads, switching Claude from web_search_20250305 to web_search_20260318 with allowed_callers defaulting to code_execution_20260120 reduces token volume by running pre-filtering scripts. Similarly, setting OpenAI search_context_size to low bounds context size for straightforward lookups.
Production Implementation and Selection Checklist
Choosing the appropriate search tool integration depends on response latency requirements, domain restrictions, citation display obligations, and budget controls. When deploying web search across these APIs, consider the following engineering steps before moving to production.
- Migrate legacy search models: transition from gpt-4o-search-preview and gpt-4o-mini-search-preview to the Responses API with web_search or gpt-5-search-api before the 2026-07-23 deprecation cutoff.
- Enforce search execution bounds: supply max_uses on Claude tools to prevent runaway search loops on ambiguous queries, using 1–3 for basic queries and higher limits near 10 for broad entity comparisons.
- Configure context density: choose search_context_size low for quick fact-checking in OpenAI to minimize prompt latency, reserving medium or high for complex summarization.
- Use asynchronous background modes: apply return_token_budget unlimited with background set to true when running multi-minute research tasks on gpt-5.5.
- Audit domain boundaries: configure up to 100 allowed_domains or blocked_domains in OpenAI, or set isolated allowed_domains or blocked_domains arrays in Claude to prevent unauthorized data retrieval.
- Parse citation offsets: implement text slicing using start_index and end_index from OpenAI url_citation annotations or Gemini model_output annotations to render verifiable hyperlinks in client frontends.
- Track query volume: monitor unique search queries in Gemini 3 models to account for the $14 per 1,000 search requests pricing once the 5,000 monthly free allocation is consumed.
For architectural guidance on managing rate thresholds and tier boundaries across providers, review /posts/rate-limits-and-usage-tiers-at-anthropic-openai-and-google/ and select target models via /posts/choosing-an-llm-api-model-by-cost-tier/.