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

# Web Search

> Enable search on the Chat Completions compatibility surface with the real request field this endpoint supports.

`Chat Completions API` enables search through the separate `web_search_options` request field. On this endpoint, search is not configured through chat `tools[]`.

Use this page when your app already depends on Chat Completions and you want search without switching to Responses.

## Request Shape

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.naga.ac/v1",
      api_key="YOUR_API_KEY",
  )

  completion = client.chat.completions.create(
      model="gpt-4.1",
      messages=[
          {
              "role": "user",
              "content": "Find recent reporting about AI regulation in the UK and cite your sources.",
          }
      ],
      web_search_options={},
  )

  print(completion.choices[0].message.content)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    baseURL: 'https://api.naga.ac/v1',
    apiKey: 'YOUR_API_KEY',
  });

  const completion = await client.chat.completions.create({
    model: 'gpt-4.1',
    messages: [
      {
        role: 'user',
        content: 'Find recent reporting about AI regulation in the UK and cite your sources.',
      },
    ],
    web_search_options: {},
  });

  console.log(completion.choices[0].message.content);
  ```

  ```bash cURL theme={null}
  curl https://api.naga.ac/v1/chat/completions \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-4.1",
      "messages": [
        {
          "role": "user",
          "content": "Find recent reporting about AI regulation in the UK and cite your sources."
        }
      ],
      "web_search_options": {}
    }'
  ```
</CodeGroup>

An empty object also enables search on providers that only need the flag itself:

```json theme={null}
{
  "model": "gpt-4.1",
  "messages": [
    {
      "role": "user",
      "content": "What are the latest AI regulation headlines?"
    }
  ],
  "web_search_options": {}
}
```

The exact nested shape under `web_search_options` can vary by model family, so start simple unless your chosen client and model require a richer config.

## Citations And Annotations

Search citations can be attached as annotations:

* non-streaming: `choices[0].message.annotations`
* streaming: `choices[0].delta.annotations`

## Common mistakes

* trying to enable search through `tools[]` instead of `web_search_options`
* assuming every model supports the same optional search configuration fields
* scraping citations out of plain text instead of reading annotations

## Caveats

* this endpoint uses `web_search_options`, not `tools: [{"type":"web_search"}]`
* the exact nested shape under `web_search_options` still depends on the model family behind the compatibility layer
* if you want the primary documented search workflow, use [Responses Web Search](/api/responses/web-search)

## Related Docs

* [Capability-level Web Search](/build/web-search)
* [Chat Completions API](/api/chat-completions)
* [Chat Completions Streaming](/api/chat-completions/streaming)
