Skip to main content
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

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)
An empty object also enables search on providers that only need the flag itself:
{
  "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