Skip to main content

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_KEY env var)
  • baseURL: Custom API endpoint URL
  • headers: Custom headers for requests

Available Models

Chat Models

  • grok-3 - Most capable Grok model
  • grok-3-mini - Smaller, faster model
  • grok-2-vision-1212 - Vision-enabled model

Agentic Models (Responses API)

  • grok-4-fast-non-reasoning - Fast agentic model
  • grok-4-1-fast-reasoning - Reasoning-enabled agentic model

Advanced Features

Web Search Tool (Responses API)

X Search Tool

Code Execution Tool

Vision

File Search Tool

MCP Server Integration

Model Capabilities

Resources