Skip to main content

xAI

xAI builds the Grok model family. AgentXchain connects via api_proxy using xAI's OpenAI-compatible API.

Which adapter?

api_proxy with provider: "openai" and a custom base_url.

Prerequisites

  • An xAI API key — get one from console.x.ai
  • XAI_API_KEY set in your environment
  • agentxchain CLI installed

Configuration

{
"runtimes": {
"grok-dev": {
"type": "api_proxy",
"provider": "openai",
"model": "grok-4.20-beta-2",
"auth_env": "XAI_API_KEY",
"base_url": "https://api.x.ai/v1/chat/completions"
}
},
"roles": {
"dev": {
"runtime": "grok-dev",
"mandate": "Implement features and fix bugs",
"authority": "proposed"
}
}
}

Available models

ModelBest for
grok-4.20-beta-2Most capable, complex reasoning
grok-4.1-fastFast, balanced performance
grok-code-fast-1Optimized for code generation

Verify the connection

export XAI_API_KEY="xai-..."
agentxchain connector check

Gotchas

  • OpenAI-compatible: Use provider: "openai" with base_url pointing to api.x.ai.
  • Beta models: Some Grok models are in beta. Check xAI's documentation for availability and rate limits.
  • Cost rates: Supply operator-specific rates since xAI models are not in the bundled defaults:
{
"budget": {
"cost_rates": {
"grok-4.20-beta-2": { "input_per_million": 3.00, "output_per_million": 15.00 }
}
}
}