Web Search Integration
Enable transparent server-side web search execution for any LLM provider. LiteLLM automatically intercepts web search tool calls and executes them using your configured search provider (Perplexity, Tavily, etc.).
Quick Start
1. Configure Web Search Interception
Add to your config.yaml:
model_list:
- model_name: gpt-4o
litellm_params:
model: openai/gpt-4o
api_key: os.environ/OPENAI_API_KEY
litellm_settings:
callbacks:
- websearch_interception:
enabled_providers:
- openai
- minimax
- anthropic
search_tool_name: perplexity-search # Optional
search_tools:
- search_tool_name: perplexity-search
litellm_params:
search_provider: perplexity
api_key: os.environ/PERPLEXITY_API_KEY
2. Use with Any Provider
import litellm
response = await litellm.acompletion(
model="gpt-4o",
messages=[
{"role": "user", "content": "What's the weather in San Francisco today?"}
],
tools=[
{
"type": "function",
"function": {
"name": "litellm_web_search",
"description": "Search the web for information",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Search query"}
},
"required": ["query"]
}
}
}
]
)
# Response includes search results automatically!
print(response.choices[0].message.content)
How It Works
When a model makes a web search tool call, LiteLLM:
- Detects the
litellm_web_searchtool call in the response - Executes the search using your configured search provider
- Makes a follow-up request with the search results
- Returns the final answer to the user
Result: One API call from user → Complete answer with search results
Supported Providers
Web search integration works with all providers that use:
- ✅ Base HTTP Handler (
BaseLLMHTTPHandler) - ✅ OpenAI Completion Handler (
OpenAIChatCompletion)
Providers Using Base HTTP Handler
| Provider | Status | Notes |
|---|---|---|
| OpenAI | ✅ Supported | GPT-4, GPT-3.5, etc. |
| Anthropic | ✅ Supported | Claude models via HTTP handler |
| MiniMax |