To reduce Grok API costs, first find out which workload and which token type are spending the money. Then work through eight levers in order: keep the prompt prefix stable and send a prompt_cache_key, move work that can wait to the Batch API, pick the model per request, set reasoning_effort per request, keep prompts under the 200,000-token line, cap the output and trim the input, pay for server-side tools and Priority Processing only where they earn it, and add a router last. On Grok the biggest single trap is the long-context rule: once a prompt reaches 200,000 tokens, every token in that request bills at double the rate, not just the tokens past the line.
This is a checklist, not a benchmark. It contains no savings percentage, because the result depends on your traffic. Prices, caching behaviour, reasoning controls and tool fees come from xAI's own developer documentation as of November 27, 2026. Third-party Grok price trackers disagree with each other and with xAI, so check the [xAI models and pricing page](https://docs.x.ai/docs/models) before you plan around a number.
Where a Grok bill comes from.
xAI bills text models per token, with separate rates for uncached input, cached input, output and reasoning, and a second, doubled rate card for long prompts:
| Per 1M tokens (Nov 2026) | Context | Input | Cached input | Output | Prompt at or above 200K tokens |
|---|---|---|---|---|---|
| grok-4.7 | 500K | $2.00 | $0.50 | $6.00 | $4.00 / $1.00 / $12.00 |
| grok-4.6 | 500K | $2.00 | $0.50 | $6.00 | $4.00 / $1.00 / $12.00 |
| grok-4.5 | 500K | $2.00 | $0.30 | $6.00 | $4.00 / $0.60 / $12.00 |
| grok-4.3 | 1M | $1.25 | $0.20 | $2.50 | $2.50 / $0.40 / $5.00 |
| grok-4.20 (reasoning, non-reasoning, multi-agent) | 1M | $1.25 | $0.20 | $2.50 | $2.50 / $0.40 / $5.00 |
Five things set the price of a given request:
- Cache hit or miss. Cached input costs 25% of uncached input on
grok-4.7andgrok-4.6, 15% ongrok-4.5and 16% ongrok-4.3. Caching is automatic. Whether you get hits depends on how you build and route the prompt. - The model.
grok-4.5throughgrok-4.7cost 1.6xgrok-4.3on input and 2.4x on output. - Reasoning. Reasoning tokens are billed, and on
grok-4.5,grok-4.6andgrok-4.7reasoning cannot be turned off and defaults tohigh. - Prompt length. At 200,000 prompt tokens or more, the whole request moves to the doubled column. The mechanic and how it compares with Gemini and OpenAI are in Grok 4.6's 200K Token Pricing Cliff.
- Service tier and tools. Batch requests get 20% off every token type. Priority requests cost 2x. Server-side tools add a fee per call on top of tokens.
API billing is separate from the SuperGrok and X Premium consumer subscriptions. A subscription does not cover API calls.
Step 0: measure before you change anything.
- The `usage` object. On Chat Completions, cached input is
usage.prompt_tokens_details.cached_tokensand reasoning isusage.completion_tokens_details.reasoning_tokens. On the Responses API they areusage.input_tokens_details.cached_tokensandusage.output_tokens_details.reasoning_tokens. Log them per request with the feature that sent it, the model, thereasoning_effort, the prompt length and theservice_tierthe response reports. - Attribution. Tag each request with your own feature name, or use a separate API key per workload, so the xAI console total can be split by product. A chargeback design is in Who Spent the Tokens?.
- Two alarms. Alert on any request with 200,000 or more prompt tokens, and on any response that reports
"service_tier": "priority"from a workload that should not be using it. Both double the price without an error.
If uncached input is the largest share, start with levers 1, 5 and 6. If reasoning tokens are a large share of output, start with levers 3 and 4. If work that can wait is a large share, start with lever 2.
The eight levers.
1. Keep the prompt prefix stable and send a prompt_cache_key
xAI caches prompt prefixes automatically: when consecutive requests share the same starting messages, the messages at the beginning that match exactly are served from cache. Cache entries are stored per server, so xAI recommends setting prompt_cache_key, or the x-grok-conv-id HTTP header, which works the same way. Requests with the same key are routed to the same server, which is where their cache lives. If both are set, prompt_cache_key wins. In practice:
- Use one key per conversation or per agent session, and keep it for the whole session.
- Put everything that does not change first: system prompt, tool definitions, reference documents, examples. Put the user's input last.
- Never edit, remove or reorder earlier messages, only append. xAI's documentation says a change to an earlier message breaks the cache from that message onward.
- On reasoning models, the reasoning of earlier turns is part of the cached prefix. If you drop it, the cache matches only up to that turn. On the Responses API, pass back the full
outputitems withincludeset toreasoning.encrypted_content, or useprevious_response_id.
If cached_tokens stays near zero on requests that share a long prefix, either the key is missing or something near the top of the prompt changes per request. Why caching comes first is in The Closest Thing to Free Money.
2. Move work that can wait to the Batch API
The Batch API takes 20% off standard rates on grok-4.7, grok-4.6, grok-4.5, grok-4.3 and the grok-4.20 models, and the discount applies to input, output, cached and reasoning tokens. Most batches complete within 24 hours, best effort. Other models reject batch requests, and image and video generation bill at standard rates. Evaluations, backfills, enrichment and nightly classification are the usual candidates. The discount is smaller than the 50% some other providers give, so check whether your job's latency budget is worth 20%. Batch discounts across providers are compared in Half Price, One Day Late.
3. Pick the model per request
grok-4.3 and the grok-4.20 family cost $1.25 input and $2.50 output per million tokens and have a 1M-token context. grok-4.5, grok-4.6 and grok-4.7 cost $2.00 and $6.00 and have a 500K context. Run classification, extraction, short summaries and most chat on the cheaper tier, and send a request type up only when you have measured that the cheaper model fails on it. Compare cost per completed task, not per token. grok-4.20-0309-non-reasoning produces no reasoning tokens at all, which matters for lever 4. In a multi-turn conversation, choose the model at the start, because a switch re-sends the whole prefix uncached. That cost is worked through in Your Router Is Fighting Your Prompt Cache.
4. Set reasoning_effort per request
The defaults differ by model, and the default is what you pay for if you never set it:
- `grok-4.7` and `grok-4.6`:
low,medium,high(default),xhigh. - `grok-4.5`:
low,medium,high(default).xhighis treated ashigh. - `grok-4.3`:
none,low(default),medium. - `grok-4.20-multi-agent`: the setting controls how many agents collaborate, not how deeply one thinks, so a higher value runs more agents.
Only grok-4.3 can turn reasoning off. On the other models a request with "none" returns a 400 error. So a lookup or formatting task sent to grok-4.7 pays for high reasoning unless you set low, and the cheaper fix is often to send it to grok-4.3 with none or to the non-reasoning grok-4.20 variant. Watch reasoning_tokens per feature and use xhigh only where you have measured that the task needs it. Cross-provider settings are in The Overthinking Tax.
5. Keep prompts under the 200,000-token line
xAI's pricing page says requests whose prompt reaches the threshold are billed at the higher rate for all tokens in the request. A 199,000-token prompt to grok-4.7 bills input at $2.00 per million. A 201,000-token prompt bills every input token at $4.00 and the output at $12.00. Cached input doubles too. Agent loops and RAG pipelines cross the line without anyone noticing, because context grows turn by turn. Put a token count in the request path, and compact or trim before the line rather than after. The grok-4.3 1M context does not avoid the rule: its long-context column doubles at the same 200,000 tokens.
6. Cap the output and trim the input
Output costs three times input on grok-4.5 to grok-4.7 and twice input on grok-4.3. Set max_tokens to what the feature needs, and ask for the format you will parse, a label or a JSON object with only the fields you read, so a malformed answer does not cost a retry. More patterns are in The Expensive Half. On input, send the relevant chunk instead of the whole document, as covered in Twenty Chunks, Three Read, drop tool definitions the request cannot use, and clear old tool results in agent loops. Trimming inside the cached prefix changes the prefix, so trim when you deploy, not on each request.
7. Pay for server-side tools and Priority Processing only where they earn it
Server-side tools are billed per call on top of token usage. Per 1,000 calls, xAI lists Web Search at $5, Code Execution at $5, File Attachments search at $5, Collections Search at $2.50, and X Search at $5 per 1,000 posts and $10 per 1,000 profiles. An agent that lets the model search freely can run several searches per turn. Turn on only the tools a feature needs, and log tool calls per request next to tokens.
Priority Processing bills at 2x standard rates on input, output, cached and reasoning tokens, and it cannot be combined with Batch. You are charged the priority rate only when the response confirms "service_tier": "priority". Use it for latency-critical user-facing paths, not as an account default. Prompt caching discounts are applied before the priority multiplier, so a cached request on priority still costs less than an uncached one.
8. Add a router last
Choosing the model and reasoning effort in code (levers 3 and 4) works until the request types blur and nobody can say which ones need grok-4.7 at high. A router helps when traffic is a real mix of easy and hard requests. It does not help when grok-4.3 already passes nearly everything, or when a switch would throw away a warm cache. We published our own negative results in When LLM Routing Does Not Help, and compared the products in How to Choose an LLM Router.
Where Nadir fits.
Nadir covers lever 8 and part of lever 4, and on Grok it can do that either in front of your traffic or beside it.
- The managed proxy takes xAI keys. Nadir's OpenAI-compatible proxy at
https://api.getnadir.com/v1executes requests with your own xAI key, as well as keys for OpenAI, Anthropic, Google, Amazon Bedrock, Groq, OpenRouter, Qwen, Kimi and MiniMax. Its xAI ladder includesgrok-4.3,grok-4.5andgrok-4.6, and xAI bills you directly at its own rates. - The decision API, without moving your traffic. The decision API returns a plan for each request, covering model, reasoning effort, cache and policy, without calling any model provider. Your code then calls xAI itself. Nadir starts in shadow mode and returns a receipt for each decision, so you can compare its choices against what you send today before you enforce anything.
Nadir costs $0.002 per request, with the first 50 a month free, and takes no markup on model spend. It also runs beside an existing gateway, including LiteLLM as the native nadir/auto provider.
Nadir does not do levers 1, 2, 5, 6 or 7 for you. Cache keys, batching, prompt length, output size and tool use are yours to change, and on Grok, where one long prompt doubles the whole request, they are often the larger share of the bill. Nadir publishes no universal savings rate. Measure first, then decide whether a router is worth adding.
The same checklist for the other platforms is How to Reduce OpenAI API Costs, How to Reduce Claude API Costs, How to Reduce Gemini API Costs, How to Reduce Amazon Bedrock Costs, How to Reduce Azure OpenAI Costs, How to Reduce Mistral API Costs and How to Reduce DeepSeek API Costs. The provider-neutral version is How to Reduce LLM API Costs.
Conclusion.
First find out which workload, which token type and which tier are spending the money. Send a prompt_cache_key and only append to the history so input bills as cached. Move work that can wait to the Batch API. Use grok-4.3 or grok-4.20 by default, set reasoning_effort instead of inheriting high, and keep prompts under 200,000 tokens. Cap the output, trim the input, and turn on tools and Priority Processing only where they pay for themselves. Add a router once the model choice needs to happen without anyone maintaining it by hand.