{"slug": "what-is-prompt-caching", "title": "What is prompt caching?", "summary": "Prompt caching cuts the cost of running AI agents by roughly 90%, since agents re-read the entire conversation on every step and would otherwise cost about 10 times as much, according to an analysis published by technically.dev. In the author's own logs, agents read between 200 and 330 tokens for every token they write, and one Claude Code session that produced 20 animation ideas took 40 steps and read 5.1 million tokens from a 10-word prompt. Anthropic's Opus 5.5 charges $4 per million input tokens but only $0.20 per million cached tokens, which priced that session at $3.17 instead of $21.18 without caching, and the author's six weeks of Claude Code and Codex usage would have cost about $78,000 at API rates without caching.", "body_md": "## The TL;DR\n\n**Prompt caching** saves the model’s work on the part it has already seen, so it only has to process what’s new.\n\n- **Agents re-read everything.** Every time an AI agent takes a step, the model has to process the whole conversation again.\n- **Caching reduces cost by 90%.** Without caching, agents would cost about 10 times as much.\n- **Three variables set the price.** How big the[cache](https://technically.dev/universe/cache) discount is, how often you hit the cache, and how long the cache lasts.\n\nIf you use off the shelf AI tools like Claude Code or Codex, caching is mostly handled for you - but it’s still helpful to know how it works under the hood.\n\n## Agents mostly read\n\nWhen we think about what a model costs to run, we usually think about the tokens it outputs. But that’s actually the smaller part of the bill.\n\nAn agent like Claude Code works in a loop. It reads the conversation, decides what to do, and calls a tool, like reading a file or running a command.\n\nThe result of that tool call gets added to the conversation, and the loop starts over. Every step is a brand new request to the model, and every request includes the entire conversation so far.\n\nYou can see where this is going.\n\nThe conversation keeps growing, and the model reads all of it again on every step. In my own logs, agents read between 200 and 330 tokens for every token they write.\n\nSome people still tell Claude to talk like a caveman to save usage, but the text the model writes is <.5% of tokens - a rounding error.\n\nFor example, I like to make animated explainer diagrams with Claude Code. So I ask it: “Read the social animations skill and give me 20 ideas.” (A skill is just a saved file of instructions.)\n\nAbout eight minutes later, I had my 20 ideas - it took 40 steps and read 5.1 million tokens. My part of that conversation was 10 words.\n\nIf the model had to re-read the prior steps tokens from scratch every turn of the loop, agents would be way too expensive to use.\n\n## What prompt caching is\n\nAs a model reads text, it builds up an internal state. Remember, models process text one [token](https://technically.dev/universe/token) at a time, and every new token updates that state. Prompt caching stores the state.\n\nFor example, here are the first 10 steps of my “20 animation ideas” session. Each step’s new tokens are in orange bars, and grey bars are “cache hits”.\n\nOn step 10, the prompt was 99,336 tokens, and 84,940 of them came from the cache, so the model only had to process the 14,396 new ones.\n\nIt’s like adding up a long receipt. If you wrote down the subtotal, you don’t add up every item again when one more gets added. You just add the new item to the subtotal.\n\nThis only works if everything before the new part is exactly the same. If something early in the conversation changes, everything after it has to be computed again.\n\nChanging one line of the system prompt, the hidden instructions sent at the start of every chat, is like changing the price of the first item on the receipt. Your subtotal is wrong now, and you have to re-add everything from that point on.\n\nStoring that internal state takes space in what’s called the “KV cache” (for a key-value store of vectors). The larger the model is, and the more tokens of [context](https://technically.dev/universe/context-window) are built up, the more space it takes.\n\nThat’s why providers don’t keep the cache around forever, but it’s still much cheaper than recomputing everything every time.\n\n## How much it saves\n\nProviders charge a lot less for cached tokens than for regular input. Opus 5.5 costs $4 per million input tokens, but only $0.20 per million cached tokens. Those 20 animation ideas cost $3.17 at [API](https://technically.dev/universe/api) prices, which would’ve been $21.18 without caching (~7x if you’re scoring at home).\n\nHere’s my own Claude Code and Codex usage from the last six weeks, priced at API rates:\n\nIt’s generally about 10 times as much without caching. For me, that’s $78,000 over six weeks at API rates, or $7,600 with the discount. For the French, that’s about 78,000 baguettes, or 7,600 baguettes, respectively.\n\nEven with caching, reading is most of the bill. On my Opus usage, the text the model writes is only 22% of the cost. Reading from the cache is 46%. The other 32% is cache writes, which is what you pay the first time something gets saved to the cache.\n\nCache writes cost 1.25x to 2x regular input depending on how long the cache lasts, so just 2% of my tokens made up 32% of the bill.\n\n## What to look out for\n\nNot every model or tool handles caching the same way. How much you save comes down to three things: the discount, the hit rate, and how long the cache lasts.\n\n### The cache discount\n\nThe first thing to check is how big the cache discount is compared to regular input tokens. If two models are identical in price but one has a much better cache discount, it’ll be a lot cheaper to run.", "url": "https://wpnews.pro/news/what-is-prompt-caching", "canonical_source": "https://read.technically.dev/p/what-is-prompt-caching", "published_at": "2026-11-24 14:46:15+00:00", "updated_at": "2026-11-24 15:13:41.123037+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "ai-infrastructure", "ai-tools"], "entities": ["Claude Code", "Codex", "Anthropic", "Opus 5.5", "technically.dev"], "also_reported_by": [], "takeaway": "Cached input tokens cost $0.20 per million versus $4 per million for regular input on Opus 5.5, so keeping the prompt prefix byte-identical across agent steps—never editing the system prompt mid-session—preserves cache hits that cut agent bills by roughly 90%.", "recommendation": {"advice": "Keep the system prompt and earlier conversation prefix unchanged across agent steps so cached tokens hit at $0.20 per million instead of $4 per million; editing one early line forces recomputation of everything after it.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/what-is-prompt-caching", "markdown": "https://wpnews.pro/news/what-is-prompt-caching.md", "text": "https://wpnews.pro/news/what-is-prompt-caching.txt", "jsonld": "https://wpnews.pro/news/what-is-prompt-caching.jsonld"}}