← All guides FrankenCoder · Cost Guide

Keeping your AI coding costs low with Anthropic

June 14, 2026·Updated June 16, 2026·12 min read·by the FrankenCoder team

A practical guide to where the money actually goes when you code with an Anthropic-powered AI agent — and the handful of settings that decide whether 1,000 turns of work costs you $37 or $550. The general lesson — smaller context is cheaper than a giant re-read every turn — applies broadly, but the cache-write premiums, 5-minute cache TTL, keep-warm heartbeat and shared-prefix savings in this guide are mostly Anthropic-specific. OpenAI, Gemini and xAI use different caching economics, so they do not need the same keep-warm strategy. None of this is guesswork: to find what actually drives the bill, we went back through our own usage — more than 340,000 messages across 600+ real coding sessions — and measured it. Skim the five-step short version below, or read on for why each one holds.

$37
per 1,000 turns · summarize at 50–100k (cheapest, measured)
$140
per 1,000 turns · push the threshold to a 1M window (~3×)
13–15×
costlier to never compress at all (some real chats hit 14M tokens)
$0
summary cost when the local model does it
The short version — five settings that keep a project cheap:
  1. Summarize at 50–100k of context — not 180k, and never let it run to 1M (§3).
  2. Let the local model write the summaries — that makes them free (§4).
  3. Leave Pre-compute summaries in background on at the recommended 80–100k threshold — unchecking it saves only ~2¢ per compaction there; it only pays off (toward ~11×) if you run very large windows (§4).
  4. Don't "never summarize" to save money — a giant window costs 3–15× and wipes continuity (§3, §5).
  5. Stay on one Anthropic model across your chats — the warm system+tools prefix is shared for an hour, but only within the same model (§7).

1. The one idea: the re-read tax

An LLM has no memory between turns. To "remember" the conversation, the entire history is re-sent on every turn. Prompt caching makes those re-sent tokens cheap — they bill at the cache-read rate (~10% of input) instead of full price — but cheap is not free. You still pay to re-read the whole prefix, every turn, and that bill grows with the conversation.

Here is the same turn, mid-conversation, in a small-window chat vs a large-window chat. Only one line changes:

200k chat · ~88k tokens deep

Re-read the cached history (88k)$0.0264
Write this turn's new work (5k)$0.0188
Generate the reply (1.5k)$0.0225
This turn$0.068

1M chat · ~450k tokens deep

Re-read the cached history (450k)$0.1350
Write this turn's new work (5k)$0.0188
Generate the reply (1.5k)$0.0225
This turn$0.176
Read it carefully: the cost of writing the new work and generating the reply is identical in both columns. The only thing that grew is the re-read — and it grew , because the chat is carrying 5× more history. A big window doesn't make any one turn smarter; it just makes you re-read more, forever.

Summarizing is what resets that re-read tax: it collapses 160k of history back down to a 3k summary, so the next 29 turns re-read a small prefix again. And the summary itself is cheap — a few cents per collapse (often free; see §4). The re-read tax, by contrast, is paid on every one of the 157 turns between summaries. That asymmetry — cheap-and-occasional vs small-but-relentless — is why avoiding summaries to "save money" backfires.

2. What does one summary actually cost?

A summary is one extra model call that fires when your context fills up. Two things set the price — which summarizer you pick, and where you set the trigger:

Here is the cost of one single summary, by window size and where you trigger it, with Pre-compute summaries in background OFF (one call at the threshold) vs ON (rewritten after every message):

WindowTrigger≈ ContextPre-compute OFFPre-compute ON
200k40%80k$0.017$0.038
50% recommended100k$0.017$0.038
60%120k$0.018$0.057
70%140k$0.018$0.057
80%160k$0.019$0.076
90%180k$0.019$0.076
272k40% ≈100k109k$0.017$0.038
50%136k$0.018$0.057
60%163k$0.019$0.076
70%190k$0.019$0.076
80%218k$0.020$0.095
90%245k$0.021$0.114
1M40%400k$0.025$0.190
50%500k$0.027$0.228
60%600k$0.030$0.285
70%700k$0.032$0.323
80%800k$0.035$0.380
90%900k$0.037$0.418

The sweet spot is a token count, not a percentage: aim to summarize around 100k of context. That's 50% of a 200k window, ~40% of a 272k window, and only ~10% of a 1M window — which is why a big window left at a high % gets pricey. Two patterns to read off the table: the OFF column barely moves (it's a single call no matter how full you let it get), while the ON column climbs steadily, because pre-compute rewrites the summary after every message and a higher trigger stacks up more messages before it fires. At the recommended ~100k it's under 4¢ a summary either way — cheap enough to leave pre-compute on for the instant turns.

3. When should it summarize? (the threshold) — measured on real chats

This is the knob you actually control: how full does the context get before we compress. Those last figures were single-turn and single-summary snapshots. The chart below is the real thing — we replayed 52,321 actual turns from 219 of our own real coding conversations through the exact prices we get billed at, sweeping the summarize threshold from 50k all the way to a 1M window. y-axis is the all-in cost to drive 1,000 turns; the x-axis is where you set the trigger. Three curves show the same sweep under three assumptions for the floor (how big the prefix is right after a summary: system prompt + tools + the ~3k bridge + pins) — because that floor, not the threshold, is the real driver, and it depends on your prompt and tool set.

$0$25$50$75$100$125$150200k350k500k650k800k950k1Msummarize threshold (context tokens)$ / 1,000 turnsoptimum$37/1k @ 50k$140/1k @ 1Mfloor 22kfloor 28kfloor 35k
Lower y is cheaper. All three curves bottom out in the 50–100k band and climb steeply after — pushing the threshold toward 1M roughly triples the bill and buys nothing.
The single takeaway: the cheapest place to summarize is 50–100k of context, not 180k and emphatically not 1M. From the optimum, every step right is more re-read tax for zero benefit — 1M costs ~3× the optimum, and never-summarizing (run the whole window) is 13–15× (off the top of the chart at $551/1,000 turns). The curve is flat-ish on the left and steep on the right, so erring low is cheap insurance and erring high is expensive.

Here is the full data behind the chart — every point, all three floor assumptions — so you can read your own setup off it instead of trusting our headline. ($ per 1,000 turns; the cheapest threshold for each floor is highlighted.)

Full table — 50k grid to 1M (click to collapse)
Threshold Xfloor 22kfloor 28kfloor 35k
50k$36.56 best$40.43 best$47.54
100k$39.84$41.38$43.27 best
150k$46.12$47.28$48.63
200k$52.62$53.55$54.63
250k$59.31$59.96$61.25
300k$65.96$66.68$67.58
350k$71.93$72.52$73.76
400k$78.23$79.03$79.41
450k$84.59$84.89$85.77
500k$89.61$90.21$91.23
550k$95.83$96.53$97.16
600k$101.14$101.82$102.31
650k$105.67$106.19$106.87
700k$110.19$111.02$111.87
750k$116.20$116.65$117.10
800k$120.99$121.49$122.48
850k$126.10$126.71$127.32
900k$130.26$130.94$131.88
950k$134.53$134.86$135.42
1M$139.63$140.08$140.57
never summarize$550.71$550.71$550.71

A note on the absolute numbers: these are averages across every conversation we looked at, and most real chats are short and never reach a high threshold — which is why the averages here sit below the single deep-turn example in §1–2. Don't anchor on the exact dollars; anchor on the shape, which never changes: cheap on the left, a steady climb to the right, and a cliff if you never compress at all.

4. Who writes the summary? (and yes, that cost counts)

The summary is produced by a separate model call — it can't share the chat's cache, so its cost is real and was easy to overlook. Two knobs decide how much it adds: which model writes the summary, and how often it fires.

Summary modelPre-computeAll-in $/turn · 200kAll-in $/turn · 1MSummary's own cost / collapse · 1M
Local modeleither$0.067$0.178$0.00 — free
Haiku (cloud)off$0.068$0.178$0.04
Haiku (cloud)on$0.070$0.180$0.42 (22 fires)
Sonnet (flagship)off$0.069$0.178$0.11
Sonnet (flagship)on$0.075$0.185$1.25 (22 fires)

Reading that table: the two all-in $/turn columns are the cost of the entire turn — almost all of it your main coding model re-reading context, which you pay no matter who summarizes — so they barely budge between rows. The summarizer only moves the last column. That's why the local-model row still shows ~$0.067 / ~$0.178: those are what the coding model charges to do the work; the summary itself is genuinely free ($0.00, last column).

But before you go unchecking it: 11× cheaper than what, and is it worth the wait? A summary's cost rides on how many user messages piled up before the window filled — and that scales with your threshold. At a small threshold an epoch holds only a message or two, so there's almost nothing to save. Here's the real cost of one compaction, with the Haiku summarizer, at the thresholds you'd actually pick:

Summarize at…Pre-compute OFFPre-compute ONYou save / compaction
50k$0.016$0.019$0.003 · 1.2×
100k (recommended)$0.017$0.038~$0.02 · 2.2×
500k$0.027$0.23$0.20 · 8.4×
900k (near max)$0.037$0.42$0.38 · 11×
So, are summary costs included? And should you turn pre-compute off? Now they're in — and the honest answer is it depends on your threshold. (1) Use the local model summarizer and the summary is genuinely free — the on/off switch doesn't matter at all. (2) With a cloud summarizer, leaving pre-compute ON keeps every turn instant; turning it OFF makes the model pause for one summary call at each compaction. That wait buys you only ~ at the recommended 80–100k, so leave it on there — it's not worth the pause. Unchecking it only pays off (climbing toward the ~11× / 20–40¢ headline) if you deliberately run very large windows. (3) Don't summarize with the flagship — Sonnet summaries cost roughly 3× Haiku's at every threshold. Either way the summary is a small slice (under 4%) of the bill — the window size is what dominates.

5. "What if I never summarize — just run to 900k and start a new chat?"

Tempting: no summarizer cost, no compression loss. But the re-read tax tells you the answer before you run it. The cost of a big chat isn't the summary — it's re-reading the giant prefix every turn, which you pay whether you summarize or not.

Strategy$/turn$/1,000 turnsContinuity
200k + summarize$0.070$703k bridge carried forward
1M @ 90% + summarize$0.180$1803k bridge carried forward
Run to 900k, never summarize, new chat$0.177$177total amnesia — 0 handoff
Worst of both worlds. Running to 900k and starting fresh costs 2.5× per turn vs a 200k chat that summarizes — and it saves only ~3% versus the 1M-with-summary path while throwing away all continuity at the reset. You pay almost the full big-window tax and get a hard memory wipe instead of a clean handoff. The summary was the cheap part; you deleted it and kept the expensive part.

6. Keeping an idle chat "warm"

Keep-warm is a provider-specific optimization, not a universal one. It matters when a provider charges extra to write a cache entry, then expires that entry quickly unless you refresh it. Of the four major providers we compared, Anthropic is the only one with both halves of that cost structure: a paid write premium and a short 5-minute message-cache TTL.

ProviderWrite premium?Guaranteed TTLFree retention windowKeep-warm verdict
AnthropicYes (1.25–2×)5 minNoneON — real savings
OpenAINoUp to 24h1–24h free retentionOFF — cache already persists
GeminiNoNone guaranteedImplicit / best-effortOFF — net-negative gamble
xAINo visible premiumn/an/aOFF — no premium to dodge

Why this mattered in real sessions

We measured the gaps in the real history, not a synthetic trace: every conversation database on the machine, 90 databases covering 3,142 conversations and 447,321 assistant turns over 125 days. The surprising part was where cold-cache returns came from. It was not mostly slow shell commands. It was ordinary human time: reading a diff, answering Slack, getting coffee, or just thinking.

53.0%
of measurable returns landed after Anthropic's 5-minute message cache was cold
19 : 1
cold returns from human pauses vs slow commands
12×
more to rewrite a context cold than to read it warm
447,321
assistant turns audited across 90 real databases

Human pauses

User messages with a measurable gap20,109
Arrived > 5 min later10,662
Arrived > 1 hour later3,042
Median gap5.8 min

Shell commands everyone blames

Shell commands run75,562
Ran longer than 5 min552
Ran longer than 1 hour50
Of all commands0.73%
The count that matters: 10,662 cold returns from pauses vs 552 from slow commands — roughly 19 to 1. The villain was not long-running tools. The villain was the pause. Thinking time. Human time.

A cold return is expensive because the token mix flips. In the trace we inspected, a normal warm turn read about 86k cached tokens and wrote only ~1.1k new tokens. The turn after a five-minute-plus gap read almost nothing from cache and wrote about 93k tokens — the whole conversation rebuilt from cold. On Anthropic Opus pricing at the time, cache read was $0.50/M, fresh input was $5.00/M, and 5-minute cache write was $6.25/M: a read was about one-twelfth the price of a write.

Why not just use Anthropic's one-hour cache?

We tried that first, and it looked great on paper: trade the 5-minute message cache for a 1-hour cache and rescue human pauses automatically. The catch is that Anthropic's 1-hour write cost was higher ($10/M vs $6.25/M), so the blanket version taxes every ordinary warm turn too. In the replay, that added +$2,609 on healthy turns while rescuing only -$1,137 of cold idle rewrites; another +$234 was wasted on returns cold for over an hour, which a one-hour cache could not help anyway.

The selective-upgrade escape hatch did not exist. We tested the live API: reading a 5-minute entry and asking for the longer lifetime billed at the cheap read price, but it did not extend the entry. The lifetime was fixed when the entry was created. The "upgraded" cache went cold at six minutes next to its control, so we threw the one-hour-cache plan away.
The decision rule: keep-warm only pays off when you must actively refresh a short, guaranteed TTL to avoid re-paying an expensive cache write. Anthropic fits that pattern; OpenAI, Gemini and xAI do not. OpenAI is the clearest contrast: cached prefixes can remain active for up to 24 hours automatically, and the retention policy does not add a separate cache-write charge, so heartbeat reads would spend money to refresh something that already survives much longer for free.

On Anthropic, your conversation's message cache expires after 5 minutes (the system prompt and tools live a full hour — that's the shared prefix in §7). If even that message cache lapses while you're away, the history must be re-written on your return — the expensive write tier. To dodge that, the keep-warm heartbeat quietly re-reads the cached history every few minutes (the cheap read tier, ~12× cheaper than a rewrite), nudging the 5-minute timer forward — but only up to a point.

< 30 min
Anthropic idle gap → keep it warm (cheaper than the ~$0.60 cold rebuild it avoids)
62.5 min
Anthropic break-even: warming costs exactly as much as one cold rebuild
> 90 min
Anthropic idle gap → let it die, rebuild on return

And the bigger the Anthropic context, the more even those cheap reads add up while you're away — priced at a mid-tier (Sonnet-class) read rate: a 160k chat burns about $0.58/hr idle, an 800k chat about $2.88/hr doing nothing (roughly 1.7× those on a flagship model). One more reason to keep context small.

What shipped is intentionally boring: a Keep Warm toggle and a small fuse indicator under the context meter. Flip it on for Anthropic, and FrankenCoder quietly spends cheap reads during normal pause-length gaps, then lets the cache lapse on long absences instead of bleeding heartbeats forever.

The chat composer with a Keep Warm toggle in the agent toggle row, and a thin fuse bar under the context meter showing how fresh the cached context is.
The Keep Warm toggle, and the fuse under the context meter that refills every time the heartbeat fires.

The cost dashboard keeps it honest. In this captured workspace, Keep Warm is just 0.4% of the bill while protecting a 43.5% prompt-cache hit rate.

The Cost Dashboard showing workspace spend broken down by model, provider, and system. The Cost by System ring lists Chat at 91.9%, Summary at 7.8%, and Keep Warm at just 0.4%, with a 43.5% prompt cache hit rate.
Cost by system: Keep Warm is 0.4% of the bill — pennies spent to protect a 43.5% cache-hit rate.

7. The shared warm prefix — a free head start across chats (same model only)

Two things sit at the very bottom of every request and never change between turns: the system prompt (instructions + standing orders + read-only workspace context) and the tool definitions (the schema for every tool the agent can call). Together they're a large, fixed block. FrankenCoder builds it to be byte-identical across every chat — no conversation name, no timestamp baked in — and caches it with a 1-hour TTL, twelve times longer than the 5-minute message cache.

Because the bytes are identical, that cache entry is shared across your chats. Warm it once — just by using the agent — and for the next hour every new chat you open finds its system prompt and tools already cached: you pay the cheap read rate (~10%) on that whole block instead of a cold write, on the very first turn of each new conversation. Open ten chats in an hour and nine of them skip rewriting the prefix entirely.

1 hr
system + tools stay cached (vs 5 min for messages)
~10%
read rate each new same-model chat pays for the prefix — not a cold write
0%
of the warm prefix is shared between different models (Opus ↔ Sonnet)
The catch — it's per model. Anthropic keys every cache entry to the exact model that wrote it, so Opus and Sonnet are different entries. If you warm the prefix in an Opus chat and then open a Sonnet chat, Sonnet starts cold — it does not inherit Opus's warm prefix (we tested exactly this). Each model warms its own prefix once, then shares it across that model's chats for the hour.

So, to actually bank the discount: pick an Anthropic model and stay on it across the chats you open in a session — model-hopping re-pays the cold prefix on every switch. This one needs no toggle and no summarizer; it's just free, as long as you don't change models. (The 5-minute message cache from §6 is the part the keep-warm heartbeat protects; this 1-hour system+tools prefix is the cross-chat freebie underneath it.)

8. The recommended setup

Cheapest sustainable (default)

Summarize around 80–100k of context · local-model summaries · one model per session · Anthropic keep-warm capped at ~30 min. Smallest re-read tax, free summaries, a warm system+tools prefix shared across all your chats, and heartbeats only where they avoid a paid short-TTL rewrite.

Pre-compute summaries: leave on

At the recommended 80–100k threshold, unchecking "Pre-compute summaries in background" saves only ~ per compaction — keep it on for instant turns. It only pays off (toward ~11×, 20–40¢ each) if you deliberately run very large windows.

1M window

A continuity feature, not a savings feature. Reach for it only when an uninterrupted reasoning chain matters more than the ~3× per-turn cost.

The whole guide in one line: with Anthropic, memory is rented by the turn, not bought once — so the cheapest agent is a small, well-summarized one, written by a free local summarizer, kept on one Anthropic model when you want shared-prefix savings — not a giant context you let run forever.

How we know this. These numbers aren't hypotheticals. We went back through our own usage — more than 340,000 messages across 600+ real coding sessions — and replayed tens of thousands of those turns through the exact prices we actually get billed at, so what you see here reflects real work, not a toy model. The single-turn walkthroughs in §1–2 follow one deep conversation so you can watch the mechanism turn by turn; the §3 chart averages the whole pile of real sessions — most of which are short — so the dollars there come out lower, but the re-read-tax shape is exactly the same. Your own bill will shift with which model you run and how tool-heavy your work is, but the ratios — and the settings that move them — hold.

← All guides