What This Unlocks
- Live web data — No more “I don’t know about recent events”
- Current information — Break free from training cutoff dates
- Automatic integration — Search results blend seamlessly into responses
- Configurable depth — Control how much web context to include
How It Works
Addweb_search_options to your API request. AnyAPI passes the search request to the model’s provider, which performs the web search and returns a response grounded in real-time data. The exact search mechanism depends on the provider — Anthropic uses its native web search tool, Google uses grounding with search, OpenAI uses its built-in search, and so on.
Chat Completions API
Basic Example
The web_search_options Parameter
| Parameter | Type | Description |
|---|---|---|
search_context_size | string | Amount of web context to include: "low", "medium" (default), or "high" |
user_location | object | Optional location for localized search results (supported by OpenAI, Anthropic, and Google models) |
Localized Search with user_location
Pass a location to get region-specific search results:
Python
Responses API
You can also use web search through the/v1/responses endpoint with the web_search_preview tool:
Search Context Levels
| Level | Context | Speed | Best For |
|---|---|---|---|
"low" | Minimal | Fastest | Quick fact-checks, simple questions |
"medium" | Balanced | Moderate | News updates, general research |
"high" | Maximum | Slowest | Deep analysis, complex research |
Real-World Examples
Latest News
Python
Deep Research with Perplexity
Python
Reasoning Over Web Results
Python
Supported Models
Web search works with 800+ models on AnyAPI, including:- OpenAI: GPT-5, GPT-5 Mini, GPT-5.4, GPT-4o, GPT-4o Search Preview, o3, o4-mini, and more
- Anthropic: Claude Opus 4.6, Claude Sonnet 4.6, Claude Haiku 4.5, and more
- Google: Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 3 Pro/Flash Preview, and more
- xAI: Grok 4, Grok 4.1 Fast, Grok 3, and more
- Perplexity: Sonar, Sonar Pro, Sonar Deep Research, Sonar Reasoning Pro
- DeepSeek: DeepSeek V3.2, DeepSeek R1, and more
- Qwen: Qwen3 Max, Qwen3 Coder Plus, Qwen3 235B, and more
- Meta: Llama 4 Maverick, Llama 4 Scout, Llama 3.1 405B, and more
- Mistral: Mistral Large, Codestral, Devstral, Magistral Small, and more
Pricing
Web search incurs an additional per-search cost on top of regular token pricing. The exact cost depends on the model and provider.Pro Tips
- Match context to your needs: Quick questions =
"low", research ="high" - Be specific in your prompts: “Tesla Q4 2025 earnings” beats “stock market”
- Use with reasoning models: Models like o3, DeepSeek R1, and Claude with extended thinking can reason over web results for deeper analysis
- Use Perplexity for research: Sonar models are built for search and return citations by default
Things to Keep in Mind
- Slight latency: Web search adds a moment to response time
- Cost scaling: Higher
search_context_sizeuses more tokens and increases cost - Rate limits: Standard rate limits apply to requests with web search
Give your AI models internet access. Web search turns any model into a research assistant that knows what happened five minutes ago.