Technically
AI Reference
Your dictionary for AI terms like LLM and RLHF
Company Breakdowns
What technical products actually do and why the companies that make them are valuable
Learning Tracks
In-depth, networked guides to learning specific concepts
Posts Archive
All Technically posts on software concepts since the dawn of time
Terms Universe
The dictionary of software terms you've always wanted

Explore learning tracks

AI, it's not that ComplicatedAnalyzing Software CompaniesBuilding Software ProductsWorking with Data Teams
Loading...
PodcastI'm feeling luckyPricing
Log In

What is prompt caching?

The thin line keeping AI agents mostly affordable.

Last updated Nov 24, 2026ai
Adam Holter
Adam Holter
Read within learning track:How AI Models Actually Work

What is prompt caching?

The thin line keeping AI agents mostly affordable.

The TL;DR#

Prompt caching saves the model's work on the part it has already seen, so it only has to process what's new.

  • Agents re-read everything. Every time an AI agent takes a step, the model has to process the whole conversation again.
  • Caching reduces cost by 90%. Without caching, agents would cost about 10 times as much.
  • Three variables set the price. How big the cache discount is, how often you hit the cache, and how long the cache lasts.

If 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.

Terms Mentioned

Schema

API

Cache

AI agent

Harness

Companies Mentioned

OpenAI logo

OpenAI

PRIVATE
Google logo

Google

ABC

Agents mostly read#

When 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.

An 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.

The 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.

You can see where this is going.

The 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.

Some 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.

For 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.)

About 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.

If 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.

What prompt caching is#

As a model reads text, it builds up an internal state. Remember, models process text one token at a time, and every new token updates that state. Prompt caching stores the state.

For 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”.

Loading image...

On 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.

It'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.

This 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.

Changing 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.

Storing 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 are built up, the more space it takes.

That's why providers don't keep the cache around forever, but it's still much cheaper than recomputing everything every time.

How much it saves#

Providers 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 prices, which would’ve been $21.18 without caching (~7x if you’re scoring at home).

Here's my own Claude Code and Codex usage from the last six weeks, priced at API rates:

Loading image...

It'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.

Even 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.

Cache 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.

Loading image...

What to look out for#

Not 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.

Continue reading with an all-access subscription

Sign up free to keep reading

In this post

  • What to look out for
  • The cache discount
  • The cache hit rate
  • How long the cache lasts
  • What this means for you

More in this track

What is Machine Learning?

How computers learn patterns from data — and why it’s the foundation for everything from stock prediction to ChatGPT.

How do Large Language Models work?

Breaking down what ChatGPT and others are doing under the hood

Free account, no credit card required. Unlocks 2 deep dives per month.

Already have an account? ·
Up Next
What is RAG?

Retrieval Augmented Generation is a way to make AI models more personalized

The post about GPUs

Why these chips pair perfectly with AI, and how NVIDIA became the most valuable company in the world.

What's going on with open-weight models?

How open-weight models went from a curiosity to great in 2 short years.

Content
  • All Posts
  • Podcast
  • Learning Tracks
  • AI Reference
  • Companies
  • Terms Universe
Company
  • Pricing
  • Sponsorships
  • Contribute
  • Contact
Connect
SubscribeSubstackYouTubeXLinkedInInstagram
Legal
  • Privacy Policy
  • Terms of Service

© 2026 Technically.