Home โ€บ AI APIs โ€บ Grok (xAI)

xAI Grok API โ€” pricing, credits & how to get a key

Grok is xAI's frontier LLM family, exposed through an OpenAI-compatible API with a very large context window and live access to X data. Its headline is cost: the Grok 4.1 Fast tier is one of the cheapest frontier-class models on the market. Here's the pricing, the free credits, and how to get a key.

Grok API pricing (reference, July 2026)

ModelInput / 1MOutput / 1M
Grok 4.1 Fast cheapest~$0.20~$0.50
Grok 4 (flagship)~$3.00~$15.00
Grok 3 mini~$0.30~$0.50
Live Search (X data)add-on, billed per source/request
โš ๏ธ Reference prices, July 2026 โ€” xAI changes model names and rates frequently and runs promotional credits. Confirm on console.x.ai / docs.x.ai. Long-context requests, cached input and Live Search are billed differently from the base token rates. ยท Report outdated price โ†’
โœ“ Last verified: 2026-07-15ยท Source: official provider pricing pageยท Auto-monitored โ€” report change โ†’

The free credits

xAI has typically offered promotional API credits rather than a permanent free tier โ€” often in exchange for opting into data sharing โ€” so the exact deal moves around. Grok chat is also included with X Premium, but that's separate from API access, which draws down a billed balance in your console. If you only need to experiment, claim whatever credit promotion is live; for production, budget per-token from the table above and price it with the calculators below.

How to get a Grok API key (step by step)

1. Go to console.x.ai and sign in with your X account.
2. Add a payment method or claim available free credits.
3. Open API Keys and create a new key โ€” copy it once (it won't be shown again).
4. Because the API is OpenAI-compatible, just change the base URL.

Call it with the OpenAI SDK shape:

# replace $XAI_API_KEY
curl https://api.x.ai/v1/chat/completions \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"grok-4-fast","messages":[{"role":"user","content":"Hello Grok"}]}'

How Grok compares on cost

Grok 4.1 Fast at roughly $0.20 / $0.50 per million tokens undercuts most frontier options โ€” cheaper on output than GPT-class mid models and far below Claude Opus. The flagship Grok 4 sits in the same band as GPT-5-class models (~$3 / $15). If cost is the priority, Grok Fast competes with Gemini Flash and DeepSeek; if you need its X-data and reasoning, the flagship is mid-pack. See the OpenAI, Claude, Gemini and DeepSeek guides, then rank them for your exact token mix with the cheapest LLM API tool.

FAQ

How much does the Grok API cost?

Per million tokens: roughly $3 / $15 for Grok 4, and ~$0.20 / $0.50 for the cheaper Grok 4.1 Fast (reference, July 2026). Confirm in the xAI console.

Is the Grok API OpenAI-compatible?

Yes โ€” it follows the OpenAI chat-completions shape, so you can reuse the OpenAI SDK and just point the base URL at api.x.ai/v1 and swap the model name.

Does Grok have a free API tier?

Usually promotional credits rather than a permanent free tier (sometimes tied to data sharing). X Premium includes Grok chat but not API access. Check the console for the current offer.

What's special about Grok?

A very large context window, strong reasoning modes, and optional Live Search over X (Twitter) data โ€” useful for real-time and social-aware applications.

Not affiliated with xAI. Prices are reference estimates โ€” always verify on the official pricing page.

Host your project:DigitalOcean โ€” $200 free โ†—Hostinger VPS

Exchanges

BybitBinanceOKXKuCoinBitgetGate.ioMEXC

Tools & Hosting

๐Ÿ“ˆ TradingView๐Ÿ”’ NordVPN๐Ÿ’ณ RevolutDigitalOcean $200Hostinger