AI glossary · Tokens and cost
What is prompt caching?
Also called: context caching
Definition
Prompt caching is an API feature that stores the processed start of a prompt, so later requests that begin with exactly the same tokens are billed at a much lower cached-input price and start answering sooner.
Explained
How does prompt caching turn input into cached tokens?
The tokens read back from that cache are your cached input tokens: the part of the prompt the provider doesn’t process again. Each response reports them in its usage data: cache_read_input_tokens on Anthropic, input_tokens_details.cached_tokens in OpenAI’s Responses API. The per-provider rules are in our prompt caching guide.
Most requests to a model repeat a long opening: the system prompt, tool definitions, a document, or the conversation so far. With caching on, the provider keeps the model’s work on that opening (the prefix) for a few minutes. If the next request starts with the identical tokens, it reads the prefix from the cache instead of processing it again.
Only an exact prefix counts. One changed character early in the prompt, such as a timestamp in the system prompt, means everything after it is new. OpenAI and Gemini cache automatically above a minimum length; Anthropic caches what you mark with cache_control, or the last cacheable block when you turn on automatic caching. Caches expire after a short idle time (Anthropic’s default is 5 minutes, refreshed on every hit), and some providers charge extra for the first write.
Example
A 20,000-token prefix reused 100 times
A support bot sends a 20,000-token system prompt and help-centre extract with every question, then a 300-token question, and gets a 400-token answer. On Claude Sonnet 5.5, input costs $2 per million tokens, a cache write $2.50 and a cache read $0.10.
Without caching, 100 questions cost $4.46. With caching, the first request writes the prefix and the other 99 read it, for $0.71 in total: 84% less, from one setting. The answers cost the same either way, because caching only discounts input.
| Without caching | With caching | |
|---|---|---|
| Prefix tokens billed at full price | 2,000,000 | 0 |
| Prefix tokens written to cache | 0 | 20,000 |
| Prefix tokens read from cache | 0 | 1,980,000 |
| Total cost | $4.46 | $0.71 |
Prices from our daily data, 2026-11-28. Assumes the requests arrive often enough to keep the cache warm.
Cost and quality
Why it matters
Input is usually most of an agent’s or chatbot’s bill, because the same context is sent on every turn. Caching is often the single largest saving available without changing the model, and it also cuts the time to the first token on long prompts.
It only pays when the prefix is reused before it expires. Slow traffic, or a prompt that changes near the top, can mean paying the write premium with no reads to recover it.
Don’t mix up
Common confusions
- Prompt caching vs response caching
- A response cache in your own code returns a stored answer to an identical question without calling the model. Prompt caching still calls the model and generates a fresh answer; only the processing of the repeated input is reused.
- Prompt caching vs the KV cache
- The KV cache is the memory a model keeps during a single request. Prompt caching keeps that work between requests, on the provider’s side, and bills it at a discount.
FAQ
Questions people ask
How do you calculate a prompt cache hit rate?
Divide cached input tokens by total input tokens over a period. On Anthropic, total input is cache_read_input_tokens plus cache_creation_input_tokens plus input_tokens; on OpenAI’s Responses API, cached tokens are reported as input_tokens_details.cached_tokens inside the input total. A low hit rate usually means something near the start of the prompt changes between requests, such as a timestamp or a reordered tool list.
Are cached input tokens free?
No, they are billed at a lower rate. On Claude Sonnet 5.5, a cache read costs $0.10 per million tokens against $2 for normal input, and writing the prefix to the cache costs $2.50. Prices are from our daily data (2026-11-28); the prompt caching calculator works out the saving for your own traffic.
Go deeper
Try it and read more
- Free toolPrompt Caching CalculatorEstimate savings from prompt caching.
- Free toolLLM API Cost CalculatorEstimate per-request, daily and monthly API costs.
- Free toolSystem Prompt LibraryOriginal system prompts with design notes, failure modes and token costs.
- Guide · 13 min readPrompt caching explained: how it works on OpenAI, Anthropic and Gemini, and when it paysPrompt caching explained: how it works on OpenAI, Anthropic and Gemini, what gets cached, minimum lengths, cache lifetimes, prices, and when it saves money.
- Guide · 13 min readHow to reduce Claude Code token usage, and what each fix costs youReduce Claude Code token usage with /clear, /compact, plan mode, exact file references, the right model and effort, a lean CLAUDE.md and fewer MCP servers.
Related