Grok API pricing starts at $2.00 per million input tokens and $6.00 per million output tokens for grok-4.7, xAI's flagship. Cached input costs $0.50, and once a prompt reaches 200K tokens, every token in that request bills at double the rate. In our tests, a short coding request on Grok 4.7 cost between $0.0065 and $0.0084, and most of that was reasoning tokens the response never shows you.
This page lists the rates for every Grok text model, then shows what 23 real calls actually billed: the same prompt on three Grok versions, a 196K versus 204K long-context pair, and a caching test that cut input cost by 72%. All calls ran through the Modellix LLM gateway, which charges xAI's list price for Grok, so the bills below are the same ones you would get direct. Image and video pricing lives on our Grok Imagine pricing page.
| Item | Grok 4.7 |
|---|---|
| Input / cached input / output | $2.00 / $0.50 / $6.00 per 1M tokens |
| Prompts of 200K tokens or more | $4.00 / $1.00 / $12.00 for the whole request |
| Context window | 500K tokens |
| Short coding call, tested | $0.0065 to $0.0084 |
| Batch API | 20% off all token types |
| Free API credits | None published; load credits before the first call |
Grok 4.7 at xAI list price, on one key
Call xai/grok-4.7, the rest of the 39-model text catalog, and the image and video APIs with one Modellix key, and see the cost of every request in the logs.
LoginGrok API Pricing by Model
xAI bills every text model per million tokens, in three lanes: fresh input, cached input, and output. Reasoning tokens count as output. The rates below are for prompts under 200K tokens.
| Model | Context | Input | Cached input | Output |
|---|---|---|---|---|
grok-4.7 |
500K | $2.00 | $0.50 | $6.00 |
grok-4.6 |
500K | $2.00 | $0.50 | $6.00 |
grok-4.5 |
500K | $2.00 | $0.30 | $6.00 |
grok-4.3 |
1M | $1.25 | $0.20 | $2.50 |
grok-4.20-0309-reasoning |
1M | $1.25 | $0.20 | $2.50 |
grok-4.20-0309-non-reasoning |
1M | $1.25 | $0.20 | $2.50 |
grok-4.20-multi-agent-0309 |
1M | $1.25 | $0.20 | $2.50 |
grok-build-0.1 |
256K | $1.00 | $0.20 | $2.00 |
For prompts of 200K tokens or more, every rate in this table doubles, and the higher rate applies to all tokens in the request, not only the ones past the threshold. Grok 4.5 has the cheapest cache lane of the 500K models ($0.30), while Grok 4.3 and the 4.20 family cost less than half as much for output and carry a 1M context window.
xAI's own rate card. Source: docs.x.ai pricing.
Modifiers that change the rate
| Option | Multiplier | Grok 4.7 input / output | What it is for |
|---|---|---|---|
| Batch API | 0.8x | $1.60 / $4.80 | Async jobs, most finish within 24 hours |
| Priority processing | 2x | $4.00 / $12.00 | Lower latency on chat and Responses calls |
| US regional endpoint | 1.1x | $2.20 / $6.60 | Inference in the US, 4.7 and 4.6 only |
| Grok 4.7 Fast | 2x | $4.00 / $12.00 | Cursor and Grok Build only, not on the API |
Batch is the only discount. It covers all the 4.x text models above except grok-build-0.1, and it does not apply to image or video generation.
Grok on the Modellix gateway
Modellix lists xai/grok-4.7, xai/grok-4.6, and xai/grok-4.5, each at the same short and long-context rates as xAI, plus a ~xai/grok-latest alias that currently resolves to Grok 4.7. The older 4.3, 4.20, and Build models are xAI-only for now.
The Grok rows on the Modellix LLM price table: no markup, so the Discount column is empty.
What a Grok API Call Actually Costs: Tested
List prices tell you the rate. They do not tell you how many tokens a model spends. We sent the same short prompt to all three Grok versions on Modellix, twice each: fix a buggy JavaScript median function and explain the bug in two sentences.
| Model | Avg time | Output tokens (reasoning share) | Billed per call |
|---|---|---|---|
| Grok 4.7 | 13.2 s | 1,050 (87%) | $0.0078 |
| Grok 4.6 | 33.6 s | 2,034 (93%) | $0.0122 |
| Grok 4.5 | 30.3 s | 1,728 (93%) | $0.0103 |
All three models have the same $2 / $6 rate card, yet Grok 4.7 came out 35% cheaper per call than Grok 4.6 and about 2.6x faster, because it reasoned for roughly half as many tokens. All three wrote a correct fix. On a cost basis, there is no reason to stay on 4.6.
Reasoning tokens are most of the bill
Between 87% and 93% of the output tokens in these calls were reasoning, billed at the full $6 output rate, while the visible answer was about 140 tokens. Reasoning cannot be switched off on Grok 4.7; reasoning_effort defaults to high and also accepts low, medium, and xhigh. On a task this small, low did not reliably save tokens: it used 994 reasoning tokens against 782 for high. Budget with output tokens from your own logs, not with the length of the answer.
Grok 4.7 adds a cached prefix to every call
Our prompt was about 36 tokens. Grok 4.7 reported 3,364 prompt tokens, 3,328 of them served from cache, on each of our short test prompts. Grok 4.6 reported 232 for the same request. At the cached rate this adds about $0.0017 per call, which is small, but it explains why your input token count will not match what you sent.
The 200K Long-Context Rule, Tested
xAI's pricing note is short: once a prompt reaches 200K tokens, the long-context rate applies to every token in the request. We checked it with two Grok 4.7 calls, one just under the line and one just over.
| Request | Prompt tokens | Rate tier | Billed |
|---|---|---|---|
| Below the line | 196,000 | Standard ($2 / $0.50 / $6) | $0.3928 |
| Above the line, prefix cached | 204,000 | Long ($4 / $1 / $12) | $0.2291 |
| Above the line, no cache (calculated) | 204,000 | Long ($4 / $1 / $12) | $0.8172 |
Both bills match xAI's formula to the cent, and the second one was billed at the long-context tier. The second request reused the first one's text, so 195,968 of its tokens were cache reads at the long-context cached rate of $1.00. Without that cache, adding 4% more tokens would have cost 2.1x as much.
Two rules follow. Keep retrieval pipelines under 200K tokens unless the extra context is worth paying double for the entire request. And if you must go over, keep the long document at the start of the prompt so repeated calls hit the cache.
Caching, Tools, and Other Grok API Costs
Prompt caching, and the header that makes it work
xAI caches matching prompt prefixes automatically, but its docs recommend an x-grok-conv-id header to raise the hit rate. We tested it with an 11K-token rule set as the system message, sending two different questions in a row.
| Second request | Cached tokens | Input cost | Billed total |
|---|---|---|---|
| No header | 1,152 | $0.0208 | $0.0240 |
With x-grok-conv-id |
11,392 | $0.0058 | $0.0082 |
Without the header, only 1,152 tokens came from cache. With it, nearly the whole prompt did, and input cost fell 72%. The header passes through the Modellix gateway unchanged; Modellix's own X-Mdlx-Session-Id header did not change cache behavior in the same test. If you reuse a long system prompt, set x-grok-conv-id to a stable value per conversation or per prompt template.
Server-side tools
Tool calls are billed on top of tokens, per 1,000 invocations:
| Tool | Cost |
|---|---|
| Web Search (includes image search) | $5 / 1K calls |
| X Search | $5 / 1K posts, $10 / 1K profiles |
| Code Execution | $5 / 1K calls |
| File attachment search | $5 / 1K calls |
| Collections search (RAG) | $2.50 / 1K calls |
The model decides how many tools to call, so an agentic request can fire several searches. X Search is billed per post or profile returned, including quoted and parent posts.
Smaller line items
A request that xAI judges to break its usage guidelines is still billed for the generation, and violations caught before generation on the Responses API cost $0.05 each. File storage costs $0.025 per GiB per day, collections $0.10, and downloads $0.20 per GiB. Image and video generation through the Imagine API are priced per image and per second; see Grok Imagine pricing.
Grok API Cost Estimates and Where to Buy
These estimates use the bills from our tests, multiplied out. Swap in your own token counts from the response usage field.
| Workload on Grok 4.7 | Per call | 10,000 calls |
|---|---|---|
| Short coding answer | $0.0078 | $78 |
| Code review, 11K-token rules, cache header on | $0.0082 | $82 |
| Same review, no cache header | $0.0240 | $240 |
| Document Q&A, 196K-token prompt | $0.3928 | $3,928 |
The cache header alone is worth about $158 per 10,000 review calls. The bigger lever is context size: one 196K-token request costs as much as 50 short coding calls.
Direct from xAI or through a gateway
| xAI direct | Modellix gateway | |
|---|---|---|
| Grok 4.7 / 4.6 / 4.5 rates | List price | Same list price |
| Older Grok models (4.3, 4.20, Build) | Yes | No |
| Batch, Priority, US endpoint | Yes | No |
| Other vendors on the same key | No | 39 text models plus image and video APIs |
| Per-request cost in the API | Yes | Yes, via GET /v1/logs |
| Free API credits | None published | None; first top-up is 10% off |
Go direct if you need Batch discounts, Priority processing, or the US endpoint. Use a gateway if Grok is one of several models in your stack and you want one key, one balance, and one log for all of them.
Why Modellix is the best way to buy Grok next to other models
Why Modellix
- Same Grok price, verified. Each of our 23 test calls billed what xAI's formula predicts, long-context tier included, never above it and within $0.0003 per call. No markup on Grok 4.7, 4.6, or 4.5.
- One key across vendors. The same key reaches 39 text models on the LLM gateway and the image and video models on the media API, so switching from Grok to another model is a one-line change.
- Costs you can audit. Every request lands in GET /v1/logs with cached, uncached, and output tokens split out and the cost attached. That is how every number on this page was produced.
Grok on the Modellix LLM gateway
Base URL, the xai/grok-4.7 model ID, Chat Completions and Responses examples, error codes, and how token billing works.
View DocsFor the setup steps, key creation, and first code sample, see our Grok API guide. For what changed in the model itself, see Grok 4.7, and for rates across vendors, the LLM API pricing comparison.
Grok API Pricing FAQ
How much does the Grok API cost?
Grok 4.7 costs $2.00 per million input tokens, $0.50 per million cached input tokens, and $6.00 per million output tokens for prompts under 200K tokens. Older models like Grok 4.3 cost $1.25 and $2.50. A short coding call on Grok 4.7 cost us about $0.008. If you want to test Grok next to other models without separate accounts, Modellix is the fastest and cheapest way to do it on one key at xAI's own price.
Is the Grok API free?
No. xAI's quickstart says to load credits before the first call, and its pricing docs publish no free API tier. With the default $0 invoiced billing limit, requests are rejected once prepaid credits run out.
What happens when a Grok prompt goes over 200K tokens?
The whole request bills at double rates: $4.00 input, $1.00 cached, $12.00 output on Grok 4.7. In our test, a 204,000-token prompt would have cost $0.8172 without cache, against $0.3928 for 196,000 tokens.
Why is my Grok bill higher than my token estimate?
Usually reasoning tokens. In our calls, 87% to 93% of output tokens were reasoning, billed at the output rate. Grok 4.7 also reports a cached prefix of about 3,328 input tokens on short prompts.
Is Grok 4.7 cheaper than Grok 4.6?
The rates are identical, but Grok 4.7 used about half the reasoning tokens on our test prompt, so each call cost 35% less and finished about 2.6x faster.
Does the Batch API make Grok cheaper?
Yes. Batch requests on the Grok 4.x text models are billed 20% below standard rates for all token types, and they do not count toward rate limits. Most complete within 24 hours. Image and video generation get no Batch discount.
Is Grok cheaper on Modellix than on xAI?
No. Modellix charges the same per-token rates as xAI for Grok 4.7, 4.6, and 4.5. The difference is access: one key and one bill across Grok and other vendors' models, with a 10% discount on the first top-up.




