xAI Grok Provider
The xAI provider enables you to use Grok models with built-in web search, X (Twitter) integration, and advanced reasoning capabilities.Installation
Setup
Get your API key from xAI Console and set it as an environment variable:Usage
Basic Text Generation
Streaming Responses
Structured Output
Configuration
Custom Provider Instance
Provider Options
- apiKey: Your xAI API key (defaults to
XAI_API_KEYenv var) - baseURL: Custom API endpoint URL
- headers: Custom headers for requests
Available Models
Chat Models
grok-3- Most capable Grok modelgrok-3-mini- Smaller, faster modelgrok-2-vision-1212- Vision-enabled model
Agentic Models (Responses API)
grok-4-fast-non-reasoning- Fast agentic modelgrok-4-1-fast-reasoning- Reasoning-enabled agentic model