Grok API pricing
What does the xAI Grok API cost?
The xAI Grok API isn't free, with text pricing starting at $1.00 per 1M input tokens on grok-build-0.1 and running up to $6.00 per 1M output tokens on grok-4.7 for standard prompts under 200k tokens. Every model charges separately for uncached inputs, cached prompt tokens, and generated completions.
If your prompt reaches 200k tokens, long context pricing kicks in immediately. At that threshold, xAI doubles the rate for every single token in the request, not just the overflow.
Grok text models and per-token pricing
xAI offers dedicated models for audio, image, video, chat, and code capabilities. For general workloads and code, the current flagship listed in the xAI documentation is Grok 4.7.
Model pricing splits into two tiers based on the size of your input prompt. As long as your prompt stays below 200k tokens, you pay standard rates. Once a prompt hits that 200k mark, the higher tier applies across the board. Cached input tokens cut the cost of repeated context down significantly (often by 75% or more).
When picking a model ID in your API calls, you've got three naming patterns to choose from. The bare model name aliases to the latest stable release. Appending -latest points to the newest version if you want new features immediately. Appending a release date pins your code to one specific release, so behavior doesn't shift under your feet.
| Model | Context Window | Prompt Tokens | Input / 1M | Cached Input / 1M | Output / 1M |
|---|---|---|---|---|---|
| grok-4.7 | 500k | < 200k | $2.00 | $0.50 | $6.00 |
| grok-4.7 | 500k | ≥ 200k | $4.00 | $1.00 | $12.00 |
| grok-4.6 | 500k | < 200k | $2.00 | $0.50 | $6.00 |
| grok-4.6 | 500k | ≥ 200k | $4.00 | $1.00 | $12.00 |
| grok-4.5 | 500k | < 200k | $2.00 | $0.30 | $6.00 |
| grok-4.5 | 500k | ≥ 200k | $4.00 | $0.60 | $12.00 |
| grok-4.3 | 1M | < 200k | $1.25 | $0.20 | $2.50 |
| grok-4.3 | 1M | ≥ 200k | $2.50 | $0.40 | $5.00 |
| grok-4.20-0309-reasoning | 1M | < 200k | $1.25 | $0.20 | $2.50 |
| grok-4.20-0309-reasoning | 1M | ≥ 200k | $2.50 | $0.40 | $5.00 |
| grok-4.20-0309-non-reasoning | 1M | < 200k | $1.25 | $0.20 | $2.50 |
| grok-4.20-0309-non-reasoning | 1M | ≥ 200k | $2.50 | $0.40 | $5.00 |
| grok-4.20-multi-agent-0309 | 1M | < 200k | $1.25 | $0.20 | $2.50 |
| grok-4.20-multi-agent-0309 | 1M | ≥ 200k | $2.50 | $0.40 | $5.00 |
| grok-build-0.1 | 256k | < 200k | $1.00 | $0.20 | $2.00 |
| grok-build-0.1 | 256k | ≥ 200k | $2.00 | $0.40 | $4.00 |
The 200k prompt token cliff
The most important detail in the table above is how xAI defines long context pricing.
On many platforms, progressive pricing only bills the excess tokens at an elevated rate. That isn't how xAI handles it. The documentation specifies that requests whose prompt reaches the listed token threshold are billed at the higher rate for all tokens in the request.
Cross that boundary by a single token, and your prices double.
Say you send 199,990 prompt tokens to grok-4.7 and get 1,000 output tokens back. You pay $2.00 per million on the input and $6.00 per million on the output. If that prompt creeps up to 200,005 tokens, every one of those 200,005 input tokens is billed at $4.00 per million, and the output jumps to $12.00 per million.
Cached inputs double as well. On grok-4.7, cached prompt tokens go from $0.50 per 1M to $1.00 per 1M. On grok-4.3 and grok-4.20, cached tokens jump from $0.20 to $0.40. If you run massive document ingestion or long chat histories, watch your token counter before submitting.
Image, video, and audio generation rates
xAI bills multimodal and generative workloads separately from standard token completions.
Vision and image input
If you send images into Grok models for visual reasoning, there is no limit on the maximum number of images per call. The file size limit is 20MiB per image, and supported file types are jpg, jpeg, and png.
Image generation
Standalone image generation uses dedicated endpoints:
- grok-imagine-image costs $0.02 per image.
- grok-imagine-image-2.0 costs $0.04 per image.
Video generation
Video models bill strictly by the duration of the generated video:
- grok-imagine-video costs $0.050 per second.
- grok-imagine-video-1.5-lite costs $0.020 per second.
- grok-imagine-video-1.5 costs $0.080 per second.
A ten-second clip on grok-imagine-video-1.5 comes out to $0.80.
Voice and speech
Audio capabilities are split between speech-to-speech interaction, plain transcription, and text-to-speech synthesis:
- Speech to Speech (grok-voice-3.0) costs $0.08 per minute ($4.80 per hour) plus $0.004 per text input. The deprecated grok-voice-2.0 runs at the exact same rates.
- Speech to Text costs $0.10 per hour over REST, or $0.20 per hour if you use the streaming interface.
- Text to Speech costs $15.00 per 1M characters.
Realtime search, reasoning, and API limits
Grok's baseline models do not know what happened this morning. The knowledge cut-off date of Grok 4.7 is May 2026.
If you want live data from the web or social feeds, you must explicitly enable server-side search tools (Web Search or X Search). Grok has no access to current events beyond its training data unless those search tools are active on the request.
Keep three other API quirks in mind when building your pipeline:
logprobsandtop_logprobsare not supported on grok-4.20 and newer models. Passing them will not throw an error, but xAI silently ignores them.- On the Responses API, grok-4.7 always returns
reasoning.encrypted_content, even when yourincludeparameter does not ask for it. - Not every xAI model accepts Batch API requests. You have to check the individual model pages in the official docs before building a Batch API workflow.
A worked cost example
Let's look at what an indie SaaS pipeline actually costs on xAI.
Suppose your application handles 20,000 requests each month using grok-4.7. Each query sends 1,200 input tokens. Because you use system instructions that stay identical between requests, 800 of those tokens hit xAI's prompt cache, leaving 400 uncached tokens. Each response averages 300 output tokens.
Here is how the text math shakes out:
- Uncached input: 20,000 × 400 = 8,000,000 tokens. At $2.00 per 1M, that's $16.00.
- Cached input: 20,000 × 800 = 16,000,000 tokens. At $0.50 per 1M, that's $8.00.
- Output: 20,000 × 300 = 6,000,000 tokens. At $6.00 per 1M, that's $36.00.
- Subtotal for text: $60.00.
Now assume that app also generates 250 preview graphics with grok-imagine-image-2.0 ($0.04 per image = $10.00) and transcribes 15 hours of customer voice memos using REST Speech to Text ($0.10 per hour = $1.50).
Your total monthly invoice comes to $71.50.
If those same 20,000 requests had pushed past the 200k prompt token boundary, that $60 text bill would have been $120. Compare these figures with What does the OpenAI API cost per million tokens? to see how xAI stacks up against standard industry baselines.
Tracking xAI spend before the invoice lands
Because xAI rates double the moment a prompt hits 200k tokens, a bug in your prompt construction or context window management can inflate an invoice fast.
That's why Costbrake monitors provider usage. Costbrake watches what you spend across 23 cloud, AI and SaaS providers (including AWS, OpenAI, Anthropic, and xAI) and alerts you on spikes, budget thresholds, month-end forecasts and new charges. Checks run hourly on the Free plan, every 5 minutes on Pro and Team, and every 2 minutes during an active spike. A spike alert triggers if an hour costs more than 3x the 7-day baseline and at least $5 over usual.
Connecting xAI takes an xAI management key with only the AnalyzeBillingItems permission, created in the xAI Console. That read-only key cannot call models, alter payment settings, or modify API credentials. xAI reports spend per hour, model, and key; because provider usage can lag, Costbrake re-reads the last 6 hours on every poll and the last 2 days every 6 hours.
If spending gets out of hand, Costbrake includes opt-in killswitches called brakes on Pro and Team plans. For xAI, brakes let you disable an API key or freeze invoiced billing at $0.01. Freezing invoiced billing stops spend that would land on an invoice, though prepaid credits keep running until exhausted. A brake never runs by itself; an admin must click and confirm it.
You can set budgets and alerts by telling your AI coding agent to handle agent setup, or connect keys manually. Pricing is flat: Free is $0 for 2 connections, Pro is $12 a month for 10 connections and brakes, and Team is $39 a month. See full details on Costbrake pricing and read How do I limit spend on the xAI API? for extra safeguards.
Questions and answers
Does Grok offer a free API tier?
No, the xAI Grok API does not have a free tier. All API requests require paid credits or an invoiced billing setup with xAI, with text models billed per million tokens starting at $1.00 for grok-build-0.1.
How does prompt caching reduce Grok API costs?
xAI bills cached input tokens at a lower rate than regular input tokens. On grok-4.7, cached prompt tokens cost $0.50 per 1M compared to $2.00 per 1M for uncached tokens, saving up to 75% on prompt costs.
What happens to billing if my prompt exceeds 200k tokens?
If your prompt reaches 200k tokens, all tokens in that request are billed at the higher long-context rate. For grok-4.7, input jumps from $2.00 to $4.00 per million, cached input rises from $0.50 to $1.00, and output jumps from $6.00 to $12.00 per million.
Does Grok have real-time internet search access?
Grok models do not have real-time access by default and rely on their training data, which has a cutoff date of May 2026 for Grok 4.7. To include current web data, you must enable server-side search tools like Web Search or X Search on the request.
Can every xAI model be used with the Batch API?
No, not every model supports xAI's Batch API. You need to review the specific model details in the xAI developer docs to verify Batch API support before implementing batch pipelines.
Sources
Updated