Launch offer50% off up to $5,000, then 3% for lifeSee offer →

PRICING · 9 MIN READ

Grok Build API Costs: What xAI's Coding Agent Bills Per Token (and How to Cut It in Half)

Grok Build on an API key bills standard per-token rates, and agent sessions multiply tokens fast. Here is what a real month costs, and the one config.toml edit that runs the same agent at 50% off.

RK

Ravi Kumar

Co-founder ·

Grok Build API Costs: What xAI's Coding Agent Bills Per Token (and How to Cut It in Half)

Grok Build API Costs: What xAI's Coding Agent Bills Per Token (and How to Cut It in Half)

Grok Build had the kind of week most developer tools never get. One post about hitting Claude Code's five hour limit and switching to Grok Build mid-session pulled over 200,000 views, and developer feeds have been full of side-by-side token-burn comparisons between coding agents ever since. A lot of the people installing it this week are about to learn something the demo clips skip: an agentic CLI is the most token-hungry way to consume an LLM API that has ever existed.

Not because the per-token prices are high. Grok pricing is aggressive. It is because agents multiply tokens. Every tool call, file read, and test run feeds more context back into the loop, and the whole growing transcript gets resent on every step. The bill is a function of the loop, not the prompt you typed.

I run billing for an API proxy, so I see what agent workloads actually cost across many accounts, not just my own terminal. This post covers how Grok Build bills when you run it on an API key, why transcript mechanics matter more than headline rates, and the one config change that runs the exact same agent at half price.

How Grok Build Billing Actually Works

The CLI itself is free. You install it with one command, and on first launch it opens a browser to sign in. In non-browser environments, or whenever you want metered billing instead, you export an API key and the agent bills standard per-token API rates for every request it makes, per the Grok Build docs:

export XAI_API_KEY="xai-..."
grok

On the API key path, what you pay is determined entirely by which model sits behind the agent. These are the three you would realistically run, at xAI list price as of August 2026, per the official pricing page:

ModelContextInput / 1MCached input / 1MOutput / 1M
grok-4.5500k$2.00$0.30$6.00
grok-build-0.1256k$1.00$0.20$2.00
grok-4.31M$1.25$0.20$2.50

Two footnotes on that table do most of the damage to real bills. First, all three models use long-context pricing: any request whose prompt reaches 200k tokens bills at double the listed rate for every token in that request. Second, the cached input column is where agent economics actually live, for reasons the next section gets into.

grok-4.5 is the model the Grok Build hype is about, and it is the one people mean when they say the agent feels like a daily driver. grok-build-0.1 is the budget coding model at half the price. For a deeper breakdown of the flagship's rates, see our Grok 4.5 API pricing guide.

Why an Agent Session Burns More Input Than You Think

A chat request sends your message once. An agent session is a loop: the model reads your instruction, calls a tool, gets the result appended to the transcript, thinks, calls another tool, and repeats until the task is done. On every single step, the entire transcript so far goes back through the input meter. A 40-step refactor does not send your prompt 40 times. It sends an ever-growing snowball of system prompt, file contents, diffs, and test output 40 times.

That is why agent workloads routinely show input-to-output ratios of 20:1 or worse, and why the input columns of the pricing table matter far more than the output column that most comparisons focus on.

The saving grace is prompt caching. xAI caches repeated prompt prefixes automatically, and a growing transcript is almost all repeated prefix. Cached input on grok-4.5 bills at $0.30 per million instead of $2.00, an 85% discount on the tokens that dominate agent traffic. xAI has been leaning into this: the Grok Build v0.2.115 release specifically improved prompt caching for long conversations to reduce repeated billing on growing transcripts. If you want to structure sessions to maximize hits, we wrote up the mechanics in our Grok 4.5 prompt caching guide.

The other thing to respect is the 200k threshold. Long agent sessions in big repos can genuinely get there, and the moment a request's prompt crosses it, every token in that request bills at double rate. Compaction and starting fresh sessions per task are not just hygiene, they are pricing decisions.

The config.toml Edit That Halves the Bill

Here is the part that most people installing Grok Build this week do not know: the CLI natively supports custom model endpoints. The docs show a first-class config block for pointing any model entry at any OpenAI-compatible base URL, with its own API key. Nothing about the agent loop changes. It is the same binary, the same model, the same tool calls, just a different endpoint collecting the money.

That matters because Grokified sells the same Grok models at 50% off xAI list price for your first $10,000 of usage (up to $5,000 saved), then 3% off for life after that. The proxy is OpenAI-compatible and passes streaming, tool calling, and structured outputs through untouched, which is exactly what an agentic CLI needs.

Add this to ~/.grok/config.toml (on Windows, %USERPROFILE%\.grok\config.toml):

[model.grokified]
model = "grok-4.5"
base_url = "https://api.grokified.com/v1"
name = "Grok 4.5 (50% off)"
env_key = "GROKIFIED_API_KEY"
api_backend = "responses"
context_window = 500000

[models]
default = "grokified"

Then export your key and confirm the CLI picked it up:

export GROKIFIED_API_KEY="gk_live_..."
grok inspect        # shows discovered config, including the new model
grok -p "Summarize this repo" -m grokified

Inside the TUI you can switch any time with /model grokified. Prefer the budget model? Set model = "grok-build-0.1" in the same block and the agent runs on the $1.00 input model at $0.50 through the proxy.

If you want to sanity-check the endpoint before wiring it into the agent, it is one curl:

curl https://api.grokified.com/v1/chat/completions \
  -H "Authorization: Bearer $GROKIFIED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "grok-4.5", "messages": [{"role": "user", "content": "ping"}]}'

Same wire format as xAI, same models, because requests are forwarded straight upstream. The base URL swap is the entire migration, the same one-line change we walk through for SDKs in using the Grok API with the OpenAI SDK.

The Math on a Real Month

Take a developer using Grok Build as a daily driver on grok-4.5: heavy sessions most working days, well-behaved caching, transcripts kept under the 200k cliff. A representative month looks like 60M input tokens, of which 45M hit cache, plus 2M output tokens.

Line itemxAI listThrough Grokified
Fresh input, 15M @ $2.00$30.00$15.00
Cached input, 45M @ $0.30$13.50$6.75
Output, 2M @ $6.00$12.00$6.00
Month total$55.50$27.75

One developer saves about $28 a month, which is real but not dramatic. The multiplication is what gets you. A ten-person team running the same workload is $555 a month versus $277.50, roughly $3,330 a year back for editing one config file. Teams running always-on agents in CI or headless mode scale the same way, except the agent never sleeps. And if your discount budget is the concern, remember the cap math works in your favor: the 50% rate covers your first $10,000 of usage before dropping to the lifetime 3%.

Every dollar in that table is billed at cached rates when xAI serves from cache, because the proxy charges from xAI's own reported cost. Caching behavior does not change when you switch the base URL; your prefix structure decides hits, not your billing endpoint.

What to Check Before You Switch

A few practical notes from watching teams move agent traffic to a discounted endpoint:

  • Keep the default xAI entry as a fallback. Custom models in Grok Build are additive. Leave the stock configuration in place and you can flip back with /model at any time, mid-project, with nothing lost.
  • Model IDs do not change. The model field still says grok-4.5 or grok-build-0.1. Only base_url and the key change, so there is no prompt or tooling migration.
  • Watch the 200k threshold either way. Long-context pricing doubles rates on both sides of the swap. Compaction and fresh sessions per task protect a discounted bill exactly as much as a full-price one.
  • Per-token billing means no usage windows. Metered API billing has no five hour session limits to hit. You pay for what the agent does, which also means an agent left looping on a broken test suite will happily spend money all night. Set a top-up budget you are comfortable with.

FAQ

Is Grok Build free to use? The CLI itself is free and open to install. The model behind it is what costs money: sign in through the browser flow, or run it on an API key and pay per token at standard API rates.

Which model does Grok Build use? grok-4.5 is the flagship that powers the current wave of attention, with a 500k context window at $2.00 per million input tokens list. The cheaper grok-build-0.1 coding model runs at $1.00 list. With a custom endpoint, both are available at half those rates.

Does pointing Grok Build at a proxy break tool calling or streaming? No. Grokified speaks the same OpenAI-compatible wire format and forwards requests upstream unchanged, so streaming, tool calls, and structured outputs behave exactly as they do against api.x.ai.

Does prompt caching still work through Grokified? Yes. Caching happens upstream based on your prompt prefixes, and cached tokens bill at the discounted cached rate. The v0.2.115 caching improvements for long conversations apply identically.

How much does the 50% discount actually save an agent user? It halves every line of the bill until you have run $10,000 of usage through it, which is up to $5,000 saved. After the cap you keep a 3% lifetime discount. For a typical heavy daily driver that is hundreds of dollars a year per developer; for teams and CI agents it compounds fast.

The Bottom Line

Grok Build earned its moment. It is fast, it does not hoard tokens the way some agents do, and running it on an API key gives you metered billing with no session windows. But an agent loop is still a token multiplier, and every multiplied token bills at whatever rate your base URL charges.

You control that base URL. One TOML block runs the same agent, the same models, and the same caching at 50% off list until you have saved $5,000.

Sign up for Grokified, grab your $5 in free credits, and point ~/.grok/config.toml at https://api.grokified.com/v1. The agent will not notice. Your invoice will.

Grok BuildGrok APIAPI PricingCoding AgentsDeveloper Tools
RK

Ravi Kumar

Co-founder, Grokified

Previously built billing infrastructure for two developer platforms. Writes about the unglamorous parts of running an API business.

Keep reading

All posts →