> ## Documentation Index
> Fetch the complete documentation index at: https://www.edenai.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LLM Web Search

> Let an LLM search the web while it answers: add web_search_options to a chat completion to ground responses in current results and sources.

**LLM Web Search**

Let an LLM search the web while it answers: add web\_search\_options to a chat completion to ground responses in current results and sources.

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. DeepSeek is the exception: on Chat Completions its models never search, and `web_search_options` does not make them search. See [DeepSeek Web Search](#deepseek-web-search) for the endpoints that search. 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

```python Python theme={null}
import requests

url = "https://api.edenai.run/v3/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

payload = {
    "model": "vertex/gemini-flash-latest",
    "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"])
```

```javascript JavaScript theme={null}
const url = 'https://api.edenai.run/v3/chat/completions';
const headers = {
  'Authorization': 'Bearer YOUR_API_KEY',
  'Content-Type': 'application/json'
};

const payload = {
  model: 'vertex/gemini-flash-latest',
  messages: [
    { role: 'user', content: 'What are the latest developments in AI regulation in 2025?' }
  ],
  web_search_options: {
    search_context_size: 'medium'
  }
};

const response = await fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(payload)
});

const result = await response.json();
console.log(result.choices[0].message.content);
```

```bash cURL theme={null}
curl -X POST https://api.edenai.run/v3/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "vertex/gemini-flash-latest",
    "messages": [
      {"role": "user", "content": "What are the latest developments in AI regulation in 2025?"}
    ],
    "web_search_options": {
      "search_context_size": "medium"
    }
  }'
```

## Supported Models

Not all models support web search. Use the [List LLM Models](https://www.edenai.co/docs/v3/llms/listing-models.md) endpoint to find models where `capabilities.supports_web_search` is `true`:

```python Python theme={null}
import requests

response = requests.get("https://api.edenai.run/v3/models")

web_search_models = [
    model["id"]
    for model in response.json()["data"]
    if (model.get("capabilities") or {}).get("supports_web_search")
]
print(web_search_models)
```

The flag is set per model and does not name an endpoint, so `true` does not mean every endpoint searches. On Qwen and DeepSeek, the models whose flag is `true` are `qwen/qwen3.8-omni-flash`, `qwen/deepseek-v4.1-flash-1017` and `deepseek/deepseek-v4-pro`. `deepseek/deepseek-v4-pro` searches on Responses and Messages, never on Chat Completions. On Messages, Eden AI sends the search tool to every DeepSeek model, including those whose flag reads `false`. See [Qwen Web Search](#qwen-web-search) and [DeepSeek Web Search](#deepseek-web-search).

> [!TIP]
>
> You can also browse models visually in the [Eden AI model catalog](https://app.edenai.run/models) and filter by capability, including web search.

> [!WARNING]
>
> **OpenAI models:** on `/v3/chat/completions`, web search only runs on the dedicated search variants (e.g. `openai/gpt-5-search-api`, `openai/gpt-5-search-api-2025-10-14`). Other OpenAI models either reject `web_search_options` with a `400` error or accept the request without performing any search. To use web search with regular OpenAI models, call them through the [Responses API](https://www.edenai.co/docs/v3/llms/responses.md) instead.

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `web_search_options` | object | Options for web search integration. Omit to disable web search. |
| `web_search_options.search_context_size` | string | Amount of context retrieved from the web. Options: `"low"`, `"medium"`, `"high"`. Default: `"medium"` |

## Qwen Web Search

`qwen/qwen3.8-omni-flash` and `qwen/deepseek-v4.1-flash-1017` search the web through Alibaba's own search. On other Qwen models the request runs without search.

* **Turn it on** with `web_search_options` on [Chat Completions](https://www.edenai.co/docs/v3/llms/chat-completions.md), or a `web_search` tool on [Responses](https://www.edenai.co/docs/v3/llms/responses.md). An `enable_search` field in your request is ignored: Eden AI sets it.
* **Messages does not search on Qwen.** A `web_search` server tool sent to a Qwen model on `/v3/v1/messages` runs no search.
* **Streaming only.** Set `stream` to `true`. A search request without it is refused with `400`.
* **Global only.** Search runs on a Global-scope workspace, so it has no EU route. A call tagged `@eu` runs on the EU workspace and does not search. See [EU data residency](https://www.edenai.co/docs/v3/data-governance/provider-data-policies.md#eu-data-residency).
* **No search rate, no search.** A search request on a model whose pricing carries no per-search rate answers `501`. The same model without a search request runs as usual.

```python Python theme={null}
import requests

url = "https://api.edenai.run/v3/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
}

payload = {
    "model": "qwen/qwen3.8-omni-flash",
    "messages": [{"role": "user", "content": "What changed in EU AI rules this month?"}],
    "web_search_options": {"search_context_size": "medium"},
    "stream": True,
}

with requests.post(url, headers=headers, json=payload, stream=True) as response:
    for line in response.iter_lines():
        if line:
            print(line.decode())
```

### Billing

A call is billed for its tokens plus the searches Alibaba reports, at the model's per-search rate (`web_search_cost_per_call`).

| Case | Billed |
| - | - |
| The model searched | The count Alibaba reports, times the per-search rate. |
| The model chose not to search, so Alibaba reports no search | No search fee. |
| The stream is cut before Alibaba reports its usage | A reservation of 10 searches. |
| Alibaba reports searches with a count that cannot be read | A reservation of 10 searches. |

## DeepSeek Web Search

DeepSeek models search the web through DeepSeek's own search, on two endpoints. Responses searches on `deepseek/deepseek-v4-pro` only. Messages sends the search tool to whichever DeepSeek model you name, and bills the searches DeepSeek reports.

* **[Responses](https://www.edenai.co/docs/v3/llms/responses.md):** add a `web_search` tool.
* **Messages (`/v3/v1/messages`):** add Anthropic's `web_search` server tool.

The model decides when to search. Web search on DeepSeek is not available on [Chat Completions](https://www.edenai.co/docs/v3/llms/chat-completions.md): a `web_search_options` field there does not make the model search.

Request body for `POST /v3/responses`:

```json theme={null}
{
  "model": "deepseek/deepseek-v4-pro",
  "input": "What is the latest stable release of Rust?",
  "tools": [{"type": "web_search"}]
}
```

Each search appears in `output` as a `web_search_call` item, and `action.queries` lists the queries it ran.

Request body for `POST /v3/v1/messages`:

```json theme={null}
{
  "model": "deepseek/deepseek-v4-pro",
  "max_tokens": 1024,
  "messages": [{"role": "user", "content": "What is the latest stable release of Rust?"}],
  "tools": [{"type": "web_search_20250305", "name": "web_search", "max_uses": 5}]
}
```

Each search appears as a `server_tool_use` block, and `usage.server_tool_use.web_search_requests` counts them.

### Limits

* **Responses searches on `deepseek/deepseek-v4-pro` only.** On `deepseek/deepseek-flash` DeepSeek ignores the tool and the request runs without search. Messages has no such restriction on the model.
* **Chat Completions does not search.** DeepSeek's chat endpoint has no search parameter.
* **Data is processed in China.** DeepSeek processes and stores requests in the People's Republic of China, and DeepSeek search carries no `eu` tag, so it has no EU route. See [EU data residency](https://www.edenai.co/docs/v3/data-governance/provider-data-policies.md#eu-data-residency).
* **No search rate, no search.** A model whose pricing carries no per-search rate answers `501` on Responses, and on Messages when the request carries a server search or fetch tool.

### Billing

A call is billed for its tokens plus its searches, at the model's per-search rate (`web_search_cost_per_call` in its `pricing`, listed by `GET /v3/models`), one query at a time. On Responses, each page the model opens counts as one query. The text it reads is counted in its input tokens.

| Case | Billed |
| - | - |
| Responses, the model searched | The queries listed in each `web_search_call` item, plus one for each page it opened, times the per-search rate. |
| Messages, the model searched | `web_search_requests` (plus `web_fetch_requests`), times the per-search rate. Without that count, one per `server_tool_use` block. |
| The model chose not to search | No search fee. |
| A search count that cannot be read | At least 10 searches. |
| A Responses stream is cut before its final event | The larger of the queries it showed and 10. |
| A Messages stream is cut before its final usage | The larger of the search blocks it showed and the reservation below. |

Every query the call ran is billed, including one that returns no results. Before the call, your balance is held for the searches as well as the tokens. Responses holds 10 searches. Messages holds the sum of the `max_uses` you set when every search tool states one. When any search tool states none, it holds that sum or 10 searches, whichever is larger.

## With System Messages

Combine web search with system messages to control how the model uses search results:

```python Python theme={null}
import requests

url = "https://api.edenai.run/v3/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

payload = {
    "model": "vertex/gemini-flash-latest",
    "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"])
```

## 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

> [!TIP]
>
> 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

> [card] [Topic Extraction](https://www.edenai.co/docs/v3/expert-models/features/text/topic-extraction.md)
>
> Extract structured topics from text with Expert Models


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.