Skip to main content
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 functionality provided by the official Search Tools in the xAI API. This allows for advanced search capabilities through web_search (internet search) and x_search (X platform search) configurations within web_search_options.

Supported Parameters

The web_search_options object accepts two main configuration objects:
  • web_search: Configuration for general internet search.
    • allowed_domains (array): List of domains to include in search.
    • excluded_domains (array): List of domains to exclude.
    • enable_image_understanding (boolean): Enable image analysis in search results.
  • x_search: Configuration for searching the X platform.
    • allowed_x_handles (array): Filter tweets from specific handles.
    • excluded_x_handles (array): Exclude tweets from specific handles.
    • from_date (string): Filter tweets after this date (ISO format).
    • to_date (string): Filter tweets before this date (ISO format).
    • enable_image_understanding (boolean): Enable image analysis in tweets.
    • enable_video_understanding (boolean): Enable video analysis in tweets.

Basic Example

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

Advanced Example

{
  "model": "grok-4-fast-reasoning",
  "web_search_options": {
    "web_search": {
      "allowed_domains": ["www.reuters.com"],
      "enable_image_understanding": true
    },
    "x_search": {
      "from_date": "2025-12-01",
      "enable_image_understanding": true,
      "enable_video_understanding": true
    }
  },
  "messages": [
    {
      "role": "user",
      "content": "Search for recent AI news."
    }
  ]
}

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://..."
    }
  }
]
The title field may not always be available depending on the model. Always use the url field to reference where information was retrieved from.