Skip to main content
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_options to your chat completion request. When enabled, the model will:
  1. Analyze the user’s query to determine if web search is needed.
  2. Search the web for relevant, current information.
  3. 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_options": {
        "search_context_size": "medium"
    }
}

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

ParameterTypeDescription
web_search_optionsobjectOptions for web search integration. Omit to disable web search.
web_search_options.search_context_sizestringAmount of context retrieved from the web. Options: "low", "medium", "high". Default: "medium"

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_options": {
        "search_context_size": "high"
    }
}

response = requests.post(url, headers=headers, json=payload)
result = response.json()
print(result["choices"][0]["message"]["content"])
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

Topic Extraction

Extract structured topics from text with Expert Models