A 100-turn coding agent running on Gemini 4 Hydrogen bills $16.80. The estimate I had in my head — first turn times 100 — said $3.44. The gap is 4.89×, and it is not a rounding error or a retry loop: it is the arithmetic of re-sending context, and it is fully predictable once you write the sum down.

Same story on the expensive model. A 50-turn deep-research run on Gemini 4 Carbon cost $11.87 at the rate in force through 2026-11-30. From 2026-12-01 that identical run — same turns, same tokens, same timestamps — bills $23.74, because Carbon's input and output rates both double. Nothing about the workload changed; the number under it did.

I rebuilt the model from the API's actual billing behaviour so the numbers could be recomputed rather than trusted. Everything below is derivable from three lines of arithmetic, and I checked each figure against a live endpoint that runs the same engine (commands at the end).

1. One turn is one call, and every call re-sends the history

An agent loop is not one request. Turn 5 sends the system prompt, turn 1, turns 2–4, and the new tool output. Turn 50 sends all of that plus 45 more turns of accumulated history.

Symbols, and the units matter:

Symbol Meaning
C0 initial context tokens
G net new history kept after a turn completes
U new user/tool content for the current turn
O visible output tokens per turn
T thinking tokens per turn
Pin, Pout USD per 1,000,000 input / output tokens

G is history that only exists after turn 1 finishes, which is why it first applies to turn 2:

context_t = C0 + (t - 1) · G input_t = context_t + U cost_t = input_t/1e6 · Pin + (O + T)/1e6 · Pout 

That (t - 1) is where most hand-built estimates go wrong by one turn — and once you are 50 turns deep, one turn of G is 3,000 tokens on every remaining call.

2. The sum is quadratic, and the coefficient is G/2

Sum the context over all turns. It is an arithmetic series:

Σ input_t = N·C0 + G·N(N-1)/2 + N·U 

The middle term is the whole story: G·N(N-1)/2 ≈ (G/2)·N². Double the turns and the input half of the bill roughly quadruples — 3.58× when going from 50 to 100 turns in my research scenario, converging on 4× as N grows, because the linear terms never quite disappear.

Compare the real total with the naive N × cost_1 estimate. After cancelling N:

total / naive = 1 + G·(N-1) / ( 2 · [ C0 + U + (Pout/Pin)·(O + T) ] ) 

Two properties fall out of this:

  • The multiplier depends on Pout/Pin, not on the absolute price level. Carbon goes 2/10 → 4/20 on 2026-12-01; the ratio stays 5, so the multiplier is identical before and after. A price change does not make your estimate any less wrong, it just makes the wrong number bigger.
  • The multiplier is a property of the workload. More growth per turn (G) or more turns (N) means a bigger gap. It has nothing to do with the vendor or the model tier.

Measured, in simulation:

Run G N Model & rate Real total Naive N × turn 1 Real ÷ naive
Short chat 700 6 Hydrogen $1.50/$7.50 $0.0819 $0.0661 1.24×
Coding assistant 1,800 20 Hydrogen $1.50/$7.50 $1.20 $0.687 1.75×
Deep research 3,000 50 Carbon pre-change $2.00/$10.00 $11.87 $4.52 2.63×
Coding assistant 1,800 100 Hydrogen $1.50/$7.50 $16.80 $3.435 4.89×
Deep research 3,000 100 Carbon pre-change $2.00/$10.00 $38.74 $9.04 4.29×

Note the last two rows: same N, same price sheet, different G, so 100-turn coding (4.89×) and 100-turn research (4.29×) land in different places. If you only ever quote one "agents cost N× more than you think" figure, you are quoting someone else's G.

The research scenario, N swept, at the pre-change $2.00/$10.00:

Turns Input tokens billed Input cost Output+thinking Total Naive Ratio
5 136,000 $0.2720 $0.2400 $0.5120 $0.4520 1.13×
20 994,000 $1.9880 $0.9600 $2.9480 $1.8080 1.63×
50 4,735,000 $9.4700 $2.4000 $11.8700 $4.5200 2.63×
100 16,970,000 $33.9400 $4.8000 $38.7400 $9.0400 4.29×

At 5 turns you barely notice the quadratic term. At 100 it is 88% of the input bill.

3. Thinking tokens: invisible on screen, priced as output

Thinking tokens are billed at the output rate, on top of the visible answer. In the model I used they are a multiple of the visible output: off 0×, low 0.5×, medium 1.5×, high 3×. Those multipliers are planning heuristics, not measured per-model factors — I use them to budget a run before executing it, not to claim what a specific model emits for a specific prompt.

The reason they deserve their own section is the arithmetic of the amplification. On the 50-turn research run:

Thinking level Thinking tokens Thinking cost Run total Share of the bill
off 0 $0.00 $10.07 0%
low 30,000 $0.30 $10.37 2.9%
medium 90,000 $0.90 $10.97 8.2%
high 180,000 $1.80 $11.87 15.2%

At high, thinking is 3.6% of all billed tokens (180,000 of 4,975,000) and 15.2% of the money, because output is priced at 5× input on these models. It never appears in the transcript, so it never appears in the review either — you find it when you open the invoice.

This is also why the 2026-12-01 change feels worse than "2× on two models". When input, output and thinking all double, the post-change total is exactly 2× the pre-change total, but the absolute delta is the one you budget against: +$11.87 per 50-turn research run.

For reference, the whole 2026-12-01 change as a lookup table — this is what "the rates doubled" means precisely:

Model Input / 1M Output / 1M On 2026-12-01
Gemini 4 Hydrogen $1.50 $7.50 Unchanged
Gemini 4 Carbon $2.00 → $4.00 $10.00 → $20.00 2× on both sides
Gemini 4 Argon $2.00 → $4.00 $10.00 → $20.00 2× on both sides

Rates verified 2026-11-28 against Google's official Gemini API pricing page and LiteLLM; Pout/Pin stays 5 for Carbon and Argon, which is why the multiplier figures above are unchanged by the price rise.

4. What actually lowers the number

Four levers, measured on the same 50-turn research run at the post-change $4.00/$20.00 rates (baseline $23.74):

Lever Result Change
Baseline: Carbon, G=3000, thinking high $23.74 —
Route the main loop to Hydrogen ($1.50/$7.50) $8.90 −62.5%
Halve retained history (G=1500) on Carbon $16.39 −31.0%
Drop thinking high → medium on Carbon $21.94 −7.6%
Route to Hydrogen and halve G $6.15 −74.1%

Read the third and fourth rows together. Temperature-tuning your thinking level is the weakest lever here (−7.6%), context discipline is a mid-strength one (−31%), and model routing is the strongest by a wide margin (−62.5%) — because Carbon's post-change output price is 2.67× Hydrogen's, and output is what thinking multiplies.

Practical version of each:

  1. Context trimming, not context summarising. The lever is G, the net history you retain. Summarise tool output before it enters the history rather than after the window fills; the cost difference between G=3000 and G=1500 above is 31%, and it compounds because every later turn pays it again.
  2. Route by role, not by prestige. Carbon/Argon for the turn that has to be right (plan decomposition, final patch), Hydrogen for the 40 mechanical turns in between. The 62.5% figure is one routing decision, not a migration project.
  3. Lower thinking on turns that cannot use it. File reads, grep results, lint fixes. The high → medium step saves 7.6% on the whole run; applied only to the non-decision turns it saves more proportionally, because thinking is priced per token, not per run.
  4. Cap N and check the ceiling. My research preset's billed input crosses a 1,048,576-token context window at turn 344 (20000 + 343·3000 + 1200 = 1,050,200). A run that cannot finish before the ceiling is paying for turns that will be truncated.

None of these are new advice. What is new — or at least, newly written down — is that they are all the same equation: G, N, Pout/Pin. You can rank them before spending anything.

5. How to recompute this yourself

Every figure in this post came out of the same four-line model, and I checked each one against a live endpoint rather than a spreadsheet. The endpoint is keyless and read-only:

curl -sS -X POST https://geminicost.craftstead.app/mcp \ -H 'Content-Type: application/json' \ -H 'Accept: application/json, text/event-stream' \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "estimate_agent_run", "arguments": { "modelId": "gemini-4-carbon", "thinkingLevel": "high", "turns": 50, "initialContextTokens": 20000, "contextGrowthPerTurn": 3000, "userToolInputTokensPerTurn": 1200, "outputTokensPerTurn": 1200, "date": "2026-11-30" } } }' 

It returns simulatedTotalUsd: 11.87, naiveEstimateUsd: 4.52, naiveMultiplier: 2.626, and an afterIncrease block that re-prices the same run at the next recorded segment (23.74). Change date to 2026-12-01 and the top-level block becomes the post-change numbers.

The rates themselves are published, not invented: checked 2026-11-28 against Google's Gemini API pricing page and LiteLLM (the table above). The formulas, the closed-form summation and the worked examples above are written out in the public docs repo with no application source code attached, so you can diff them against your own invoice instead of taking my word for it. The interactive version is Gemini Cost Simulator if you would rather move sliders than write curl.

Two caveats worth stating plainly. First, the model bills list prices only — no batch discounts, no caching credits, no committed-use pricing; if you use prompt caching, your real bill will be lower than these numbers, potentially by a lot, and the saving scales with G exactly the way the cost does. Second, the thinking multipliers are budget heuristics; replace them with your own measured ratios and the rest of the arithmetic still holds.

Disclosure: this article was written with AI assistance. Every number in it was computed by the model described above, cross-checked against the live endpoint shown in section 5, and written up by me; the code and data links are my own projects.