TokenMix Research Lab · 2026-04-24
Grok API Key: How to Get Access + Pricing 2026
Last Updated: 2026-04-24
Author: TokenMix Research Lab
Getting a Grok API key in 2026 requires an xAI developer account — the process takes 5 minutes and gives you access to Grok 3, Grok 4 Fast, Grok 4.1 Fast (Reasoning and Non-Reasoning), and Grok 4.20 Beta. Pricing: $3 input / $15 output per MTok on the flagship Grok 4 models, $0.50/$2.50 on Grok 4 Fast, with Grok 4.1 Fast Reasoning at $2.50/$12.50. Free tier: limited to 10 requests/min on Grok 4 Fast Non-Reasoning. This guide covers the signup walkthrough, how to verify your key works, pricing comparisons vs GPT-5.4 and Claude Opus 4.7, and the SpaceX-xAI IPO context that's driving rate-limit tightening. TokenMix.ai exposes all Grok variants via one OpenAI-compatible endpoint — useful if you want Grok + multi-provider fallback.
Table of Contents
- Confirmed vs Speculation
- xAI Signup in 5 Minutes
- Grok Model Pricing Tiers
- First API Call: curl + Python
- vs GPT-5.4 and Claude Opus 4.7
- Common Errors When Setting Up
- FAQ
Confirmed vs Speculation
| Claim | Status | Source |
|---|---|---|
| Grok API access via x.ai/api | Confirmed | xAI developer portal |
| Grok 4 $3/$15 per MTok | Confirmed | Pricing docs |
| Grok 4 Fast $0.50/$2.50 | Confirmed | |
| Free tier 10 req/min Fast Non-Reasoning | Confirmed | Rate limit page |
| OpenAI-compatible endpoint | Confirmed | API reference |
| xAI acquired by SpaceX Feb 2026 | Confirmed | SpaceX-xAI merger |
| Grok 5 release date announced | No — speculation | |
| API reliability | Variable — 2 outages in April 2026 | status.x.ai |
Snapshot note (2026-04-24): Grok 4.20 Beta's 4-agent architecture (Grok + Harper + Benjamin + Lucas) and the 83% non-hallucination figure are xAI-reported; independent reproductions are limited. Grok's SWE-Bench Verified ~70% vs Claude Opus 4.7 87.6% draws from a mix of xAI posts and community testing. Pricing is current per x.ai/pricing — SpaceX-xAI merger may drive tier tightening, re-verify before billing commitments.
xAI Signup in 5 Minutes
Step 1 — Create xAI account:
- Go to x.ai/api
- Sign up with email (or GitHub)
- Verify email
Step 2 — Add billing:
- Developer dashboard → Billing
- Add credit card (required even for free tier, for rate limit scaling)
- Optionally prepay $10-50 to start with buffer
Step 3 — Generate API key:
- Developer dashboard → API keys → Create new key
- Name it (e.g., "local-dev", "production")
- Copy immediately — key is shown only once
Step 4 — Test:
curl https://api.x.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_XAI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4-fast-non-reasoning",
"messages": [{"role":"user","content":"Hello Grok"}]
}'
Success = JSON response with choices[0].message.content.
Grok Model Pricing Tiers
| Model | Input $/MTok | Output $/MTok | Context | Best for |
|---|---|---|---|---|
| grok-3 | $0.30 | $1.50 | 131K | Budget general |
| grok-3-mini | $0.15 | $0.60 | 131K | Cheap chat |
| grok-4 | $3.00 | $15.00 | 1M | Flagship general |
| grok-4-fast-non-reasoning | $0.50 | $2.50 | 2M | Latency-critical |
| grok-4-fast-reasoning | $2.00 | $10.00 | 2M | Fast reasoning |
| grok-4.1-fast-non-reasoning | $0.50 | $2.50 | 2M | Current fast |
| grok-4.1-fast-reasoning | $2.50 | $12.50 | 2M | Current reasoning |
| grok-4.20 Beta | $3.00 | $15.00 | 2M | 4-agent multi |
Key tiers:
- Ultra-cheap: Grok 3 Mini ($0.15-0.60)
- Budget: Grok 4 Fast Non-Reasoning ($0.50-2.50) — best price/performance
- Premium: Grok 4 / 4.20 ($3/$15) — full capability tier
- Reasoning: Grok 4.1 Fast Reasoning ($2.50/$12.50) — 3-5s latency
First API Call: curl + Python
Python using OpenAI SDK (Grok is OpenAI-compatible):
from openai import OpenAI
client = OpenAI(
api_key="your_xai_key",
base_url="https://api.x.ai/v1"
)
response = client.chat.completions.create(
model="grok-4.1-fast-reasoning",
messages=[{"role": "user", "content": "Explain dark matter in 3 sentences."}]
)
print(response.choices[0].message.content)
Or via TokenMix.ai for multi-provider routing:
client = OpenAI(
api_key="your_tokenmix_key",
base_url="https://api.tokenmix.ai/v1"
)
# Now call model="xai/grok-4.1-fast-reasoning"
vs GPT-5.4 and Claude Opus 4.7
| Model | Input $/MTok | Output $/MTok | SWE-Bench Verified | Non-halluc. rate |
|---|---|---|---|---|
| Grok 4 | $3.00 | $15.00 | ~70% | 80% |
| Grok 4.20 Beta | $3.00 | $15.00 | ~70% | 83% (4-agent) |
| GPT-5.4 (xhigh) | $2.50 | $15.00 | ~82% | 76% |
| Claude Opus 4.7 | $5.00 | $25.00 | 87.6% | 82% |
| Gemini 3.1 Pro | $2.00 | $12.00 | 80.6% | 75% |
Grok 4.20's 4-agent architecture is the differentiator for reasoning-sensitive queries. For pure coding, Claude Opus 4.7 wins. For general chat at low cost, GPT-5.4 or Grok 3 Mini.
Common Errors When Setting Up
Error: 401 Unauthorized
→ API key wrong or missing Bearer prefix in header
Error: 403 Rate limit exceeded
→ Free tier only gives 10 req/min. Upgrade billing tier or switch to paid model.
Error: Model not found: grok-4
→ Use exact ID grok-4 or grok-4-0709 — case-sensitive. Newer models may require explicit version suffix.
Error: Service unavailable (503)
→ xAI outage, check status.x.ai. Common during IPO-related demand spikes. Use multi-provider fallback.
Error: Context length exceeded
→ Some variants (Grok 3) cap at 131K. Switch to Grok 4 or Grok 4 Fast for 1M-2M context.
FAQ
Does Grok have a free API tier?
Yes — grok-4-fast-non-reasoning offers 10 requests/minute free. Enough for dev prototyping. For production, paid tier required.
What's the difference between Grok 4 and Grok 4.20?
Grok 4 is single-model flagship. Grok 4.20 Beta adds 4-agent parallel architecture (Grok + Harper + Benjamin + Lucas) with 83% non-hallucination rate. Grok 4.20 is 3-4× slower due to cross-verification. Use Grok 4 for latency-critical, 4.20 for accuracy-critical. See Grok 4.20 review.
Is Grok reliable for production?
Moderate reliability. Two multi-hour outages in April 2026 post-SpaceX-merger. For mission-critical paths, always implement fallback routing through TokenMix.ai or similar gateway.
What rate limits should I expect?
Tier 1 (new account): 10 req/min free model, 60 req/min paid. Tier 4 (after $400+ spend): 200-400 req/min. Custom enterprise tiers negotiate higher. See xAI rate limits.
Can I use Grok for coding?
Yes, but SWE-Bench Verified ~70% lags Claude Opus 4.7 (87.6%) and GLM-5.1. For production coding, Claude or GLM. For general chat where code questions occasionally come up, Grok is adequate.
Does Grok support image input?
Grok 4 and 4.20 have vision capabilities. Send images via standard OpenAI-compatible image message format. Quality is solid but below Claude Opus 4.7's 3.75MP visual acuity.
How does Grok handle politically sensitive content?
Less restricted than Claude or GPT on political topics — one of xAI's brand differentiators. For production with safety requirements, add your own guardrails — Grok's default behavior is more permissive.
Sources
- xAI Developer Portal
- xAI Pricing
- xAI Status Page
- Grok 4.20 Multi-Agent Review — TokenMix
- Grok 4.1 Fast Reasoning — TokenMix
- SpaceX-xAI Merger — TokenMix
- Grok API Pricing — TokenMix
By TokenMix Research Lab · Updated 2026-04-24