Skip to main content

Web Search

NagaAI supports web search integration for certain models. This feature allows models to access real-time information from the web to provide up-to-date and accurate responses.

Supported Models

Grok, OpenAI (most models), Google, and Sonar models support web search.

Overview

Web search enables models to retrieve and use current information from the internet when responding to queries. You control web search behavior through the web_search_options parameter in your Chat Completions request.

Configuration

Using web_search_options

Include the web_search_options parameter in your request to enable and configure web search behavior for supported models.

Model-Specific Behavior

Below are examples and configuration details for each provider that supports web search:

Web search is optional for Grok models. To enable it, include the web_search_options parameter with an empty object {} or with specific configuration options.

We support all parameters supported by the official Live Search in the xAI API. However, in our API, use web_search_options instead of search_parameters. All nested parameters are supported.

Basic Example

{
"model": "grok-4-fast-reasoning",
"web_search_options": {},
"messages": [
{
"role": "user",
"content": "What is the current date and time according to CET?"
}
]
}

Getting Citations

To retrieve citations (sources) from web search results, include "return_citations": true in the web_search_options:

{
"model": "grok-4-fast-reasoning",
"web_search_options": {
"return_citations": true
},
"messages": [
{
"role": "user",
"content": "What are the latest AI developments?"
}
]
}

Retrieving Citations

Citations from web search results are available for all search-enabled models (Grok, OpenAI, Google, and Sonar). They can be accessed via the annotations field in the response.

Accessing Citations

The location of citations depends on whether you're using streaming or non-streaming mode:

  • Non-streaming responses: choices[0].message.annotations
  • Streaming responses: choices[0].delta.annotations

Citation Structure

Citations are returned as an array. Each citation contains the source URL and may include the page title:

[
{
"type": "url_citation",
"url_citation": {
"title": "Page title...",
"url": "https://..."
}
}
]
note

The title field may not always be available depending on the model. Always use the url field to reference where information was retrieved from.