> ## Documentation Index
> Fetch the complete documentation index at: https://edenai-docs-github-copilot-integration.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Web Search

> Web search lets LLMs access real-time information from the internet when generating responses.

export const TechArticleSchema = ({title, description, path, articleSection, about, proficiencyLevel = "Beginner", dependencies, keywords = [], datePublished, dateModified, image, inLanguage = "en"}) => {
  const baseUrl = "https://www.edenai.co/docs";
  const canonicalUrl = `${baseUrl}/${path}`.replace(/\/+$/, "");
  const ogParams = new URLSearchParams({
    division: articleSection || "",
    title: title || "",
    description: description || ""
  });
  const resolvedImage = image || `https://edenai.mintlify.app/_mintlify/api/og?${ogParams.toString()}`;
  const data = {
    "@context": "https://schema.org",
    "@type": "TechArticle",
    "@id": `${canonicalUrl}#techarticle`,
    mainEntityOfPage: {
      "@type": "WebPage",
      "@id": canonicalUrl
    },
    headline: title,
    name: title,
    description: description,
    url: canonicalUrl,
    inLanguage: inLanguage,
    isPartOf: {
      "@type": "WebSite",
      name: "Eden AI Documentation",
      url: baseUrl
    },
    author: [{
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/"
    }],
    publisher: {
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/",
      logo: {
        "@type": "ImageObject",
        url: "https://www.edenai.co/assets/logo.png"
      }
    }
  };
  if (articleSection) data.articleSection = articleSection;
  if (about) data.about = {
    "@type": "Thing",
    name: about
  };
  if (proficiencyLevel) data.proficiencyLevel = proficiencyLevel;
  if (dependencies) data.dependencies = dependencies;
  if (keywords && keywords.length) data.keywords = keywords;
  if (datePublished) data.datePublished = datePublished;
  if (dateModified) data.dateModified = dateModified;
  data.image = Array.isArray(resolvedImage) ? resolvedImage : [resolvedImage];
  const json = JSON.stringify(data);
  const schemaId = `techarticle-${canonicalUrl}`;
  React.useEffect(() => {
    if (typeof document === "undefined") return;
    document.querySelectorAll(`script[data-schema-id="${schemaId}"]`).forEach(n => n.remove());
    const script = document.createElement("script");
    script.type = "application/ld+json";
    script.dataset.schemaId = schemaId;
    script.textContent = json;
    document.head.appendChild(script);
    return () => script.remove();
  }, [json, schemaId]);
  return null;
};

<TechArticleSchema title={"Web Search"} description={"Web search lets LLMs access real-time information from the internet when generating responses."} path="v3/llms/web-search" articleSection="LLMs" about={"LLM API"} proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "LLM API", "chat completion", "OpenAI compatible"]} datePublished="2026-05-06T00:00:00Z" dateModified="2026-05-07T00:00:00Z" />

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

<CodeGroup>
  ```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": "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"])
  ```

  ```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: 'openai/gpt-4o',
    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": "openai/gpt-4o",
      "messages": [
        {"role": "user", "content": "What are the latest developments in AI regulation in 2025?"}
      ],
      "web_search_options": {
        "search_context_size": "medium"
      }
    }'
  ```
</CodeGroup>

## Supported Models

Not all models support web search. Use the [List LLM Models](/v3/llms/listing-models) endpoint to find models where `capabilities.web_search` is `true`.

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

## With System Messages

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

<CodeGroup>
  ```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": "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"])
  ```
</CodeGroup>

## 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.
</Tip>

## Next Steps

<CardGroup cols={2}>
  <Card title="Topic Extraction" icon="font" href="/v3/expert-models/features/text/topic-extraction">
    Extract structured topics from text with Expert Models
  </Card>
</CardGroup>
