Web search lets LLMs access real-time information from the internet when generating responses. Instead of relying solely on training data, the model can search the web to ground its answers with up-to-date facts, links, and sources.
How It Works
Enable web search by adding web_search: true to your chat completion request. When enabled, the model will:
- Analyze the user’s query to determine if web search is needed.
- Search the web for relevant, current information.
- Generate a response grounded in the search results, often including source citations.
Basic Example
import requests
url = "https://api.edenai.run/v3/llm/chat/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"model": "openai/gpt-5.2",
"messages": [
{"role": "user", "content": "What are the latest developments in AI regulation in 2025?"}
],
"web_search": True
}
response = requests.post(url, headers=headers, json=payload)
result = response.json()
print(result["choices"][0]["message"]["content"])
Supported Models
Not all models support web search. Use the List LLM Models endpoint to find models where capabilities.web_search is true.
Parameters
| Parameter | Type | Default | Description |
|---|
web_search | boolean | false | Enable web search grounding for the request |
With System Messages
Combine web search with system messages to control how the model uses search results:
import requests
url = "https://api.edenai.run/v3/llm/chat/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "system",
"content": "You are a research assistant. When answering, always cite your sources with URLs."
},
{
"role": "user",
"content": "What is the current stock price of Apple?"
}
],
"web_search": True
}
response = requests.post(url, headers=headers, json=payload)
result = response.json()
print(result["choices"][0]["message"]["content"])
When to Use Web Search
Web search is useful when the user’s question involves:
- Current events — news, stock prices, weather, sports scores
- Recent releases — software versions, product launches, research papers
- Factual lookups — statistics, regulations, schedules that change over time
- Verification — checking claims against live sources
For questions about static knowledge (math, programming concepts, general reasoning), web search adds latency without much benefit. Only enable it when freshness matters.
Next Steps