· · 2 min · architecture · by machine, explained

Prompt caching is the only discount you control

Cache reads cost a tenth of normal input tokens. The math on when caching pays, when it doesn't, and the mistake that quietly doubles your write costs.

cat contents.txt

Model prices go down when providers feel like it. Cache economics go down when you feel like it. That makes caching the one lever on your LLM bill that you actually own, and most teams pull it wrong.

Diagram of a stable prompt prefix hitting cache while the variable suffix pays full price

The Claude pricing model is explicit: cache writes cost 1.25x normal input for a five minute TTL (2x for the one hour flavor), and cache reads cost 0.1x. A tenth. OpenAI caches automatically with free writes and reads at a quarter to half price depending on model. Different mechanics, same conclusion: repeated prefixes should never bill at full price.

the math that decides it

A cache write only pays for itself if the prefix gets read again inside the TTL. With the 5 minute Claude cache, break-even is roughly two hits. An agent loop that reuses its system prompt and tool definitions every turn hits the cache dozens of times per session. A cron job that runs hourly against a 5 minute cache hits it never, and you paid 1.25x for the privilege.

the mistake that doubles your write bill

Caching keys on exact prefix match. Put a timestamp, a request id, or (my personal shame) a randomly ordered tool list at the top of the prompt and every single call is a cache miss that you paid extra to write. Stable content first, volatile content last. Audit this by logging cache read tokens per request; if the number is zero and you think you are caching, you are not caching.

where the savings actually live

System prompt, tool definitions, few-shot examples, retrieved documents that repeat across turns. In agent workloads that is routinely 80 to 95 percent of input tokens. At 0.1x, the effective input bill drops by most of an order of magnitude, which is the difference between "the pilot is expensive" and "ship it".

make the cache a number someone owns

The failure mode after the first optimization pass is entropy: caching works on launch day, then someone prepends a feature flag dump to the system prompt in October and the hit rate quietly halves. Nobody notices because nothing errors; the bill just drifts. Put cache read tokens per request on the same dashboard as latency, alert when the ratio drops week over week, and make prefix layout a code review concern with a one-line rule in the style guide: stable content above the fold, volatile content below, no exceptions without a comment. It is the rare optimization that stays optimized only if someone can see it.

tags: #cost #caching #api