← directory / providers / xai
xAI API
first-party10
models served
XAI_API_KEY
auth
api.x.ai/v1
base url
OpenAI-compatible (also Anthropic-compatible endpoint available). docs →
01Request template
Every model below is invoked with this shape — swap in the provider model ID from the table.
curl https://api.x.ai/v1/chat/completions \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "{{MODEL_ID}}",
"messages": [{"role": "user", "content": "Hello, world"}]
}'02Models served · newest first
| Model | Provider model ID | In $/M | Out $/M | Context |
|---|---|---|---|---|
| Grok 4.6xAI | grok-4.6 | — | — | 500K |
| Grok 4.5xAI | grok-4.5 | — | — | 500K |
| Grok 4.3xAI | grok-4.3 | 1.25 | 2.50 | 1M |
| Grok Build 0.1xAI | grok-build-0.1 | — | — | 256K |
| Grok 4.20 (Non-Reasoning)xAI | grok-4.20-0309-non-reasoning | — | — | 1M |
| Grok 4.20 (Reasoning)xAI | grok-4.20-0309-reasoning | — | — | 1M |
| Grok 4.1 FastxAI | grok-4.1-fast | 0.20 | 0.50 | 2M |
| Grok 4 FastxAI | grok-4-fast | 0.20 | 0.50 | 2M |
| Grok Code Fast 1xAI | grok-code-fast-1 | 0.20 | 1.50 | 256K |
| Grok 4xAI | grok-4 | 3.00 | 15.00 | 256K |
Dimmed prices are canonical — this provider's own quote isn't captured yet.