How to Reduce Grok API Costs

A Grok API bill is uncached input, cached input, output and reasoning tokens, multiplied by the model, the prompt length and the service tier. Once a prompt reaches 200,000 tokens, every token in the request bills at double the rate. Find out which workload and token type are spending the money first. Then work through eight levers in order: keep the 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, stay under the 200K line, cap the output and trim the input, use server-side tools and Priority Processing only where needed, and add a router last. No savings percentage, because the result depends on your traffic.

Published 2026-11-27 by Dor Amir on the Nadir blog.

Filed under Pricing & Models.

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)ContextInputCached inputOutputPrompt at or above 200K tokens
grok-4.7500K$2.00$0.50$6.00$4.00 / $1.00 / $12.00
grok-4.6500K$2.00$0.50$6.00$4.00 / $1.00 / $12.00
grok-4.5500K$2.00$0.30$6.00$4.00 / $0.60 / $12.00
grok-4.31M$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:

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.

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:

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:

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.

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.

More on pricing & models

Pages on this site

Machine-readable summaries of this site: llms.txt and llms-full.txt.