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
Advanced Features
Live Search
Web Search Tool (Responses API)
X Search Tool
Code Execution Tool
Vision
File Search Tool
MCP Server Integration
Model Capabilities
| Model | Vision | Tools | Web Search | X Search |
|---|---|---|---|---|
| grok-3 | ✗ | ✓ | ✓ | ✗ |
| grok-3-mini | ✗ | ✓ | ✓ | ✗ |
| grok-2-vision-1212 | ✓ | ✓ | ✓ | ✗ |
| grok-4-fast-non-reasoning | ✗ | ✓ | ✓ | ✓ |
| grok-4-1-fast-reasoning | ✗ | ✓ | ✓ | ✓ |