Skip to content

xAI

provider: 'xai'

The xAI provider reaches Grok models through xAI's first-party OpenAI-compatible API (https://api.x.ai/v1). Grok is also available through Vertex AI and OpenRouter.

Authentication

Get an API key from the xAI Console and pass it through extra.apiKey:

ts
{
  provider: 'xai',
  model: 'grok-4-3',
  extra: { apiKey: process.env.XAI_API_KEY },
}

Configuration

FieldRequiredDescription
extra.apiKeyRecommendedxAI API key. The base URL is fixed to https://api.x.ai/v1.

Models

Modelmodel
Grok 4.3grok-4-3

JSON output

Grok uses the OpenAI-compatible response_format: json_schema (strict: true) for schema-enforced JSON. See JSON output and schemas. temperature is not sent.