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 theweb_search_options parameter in your Chat Completions request.
Configuration
Using web_search_options
Include theweb_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:- Grok
- OpenAI
- Google
- Sonar
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
Getting Citations
To retrieve citations (sources) from web search results, include"return_citations": true in the web_search_options:Retrieving Citations
Citations from web search results are available for all search-enabled models (Grok, OpenAI, Google, and Sonar). They can be accessed via theannotations 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:The
title field may not always be available depending on the model. Always
use the url field to reference where information was retrieved from.