Setup
Basic Usage
Parameters
str
default:"grok-3"
Model identifier. Common values:
grok-3, grok-2.str
xAI API key. Defaults to the
XAI_API_KEY environment variable.str
default:"https://api.x.ai/v1"
xAI API base URL.
float
Sampling temperature.
int
Maximum output tokens.
dict
Configuration for Grok’s live search capabilities.
Live Search
xAI Grok models can search the web for real-time information:Streaming
Async Usage
xAI uses an OpenAI-compatible API with extensions for live search. Citations are returned in the response when search is enabled.