Prompt caching is a feature of AI APIs that stores the processed version of the repeated opening of your prompt, so later requests that start the same way are read from the cache at a fraction of the normal input price and come back faster. It changes nothing about the answer. It only changes what you pay and how long you wait. At Saraswati Stitch it is one of the first things we switch on for any assistant with a long system prompt or a shared document, because it is often the cheapest saving available.
How it works
Every request to a language model has to be processed from the first token. If each request begins with the same 20,000 tokens of instructions, product data or policy text, the provider does that same work every time. With caching, the provider keeps the processed state of that opening section, called the prefix, for a short period. The next request that begins with exactly the same prefix skips that work.
Two rules decide whether it works. The prefix has to match exactly, character for character, including tools and images. And the repeated part has to come first, with the changing part, such as the user question, at the end.
What it costs on Claude and OpenAI
| Anthropic (Claude) | OpenAI | |
|---|---|---|
| How you turn it on | Mark the prefix with cache_control, or use automatic caching | On by default for supported models, with optional explicit breakpoints |
| Price to write the cache | 1.25 times base input for a 5 minute cache, 2 times for a 1 hour cache | 1.25 times base input for the default 30 minute cache, 2.5 times for a 12 hour cache (GPT-5.6 and later) |
| Price to read the cache | 0.1 times base input | 0.1 times base input on most recent models, 0.05 times on some |
| Minimum prefix length | 512 tokens on current models, 1,024 on some older ones | 1,024 tokens on GPT-5.6 and later |
| How long it lasts | 5 minutes by default, refreshed free each time it is used; 1 hour option | At least 30 minutes by default; 12 hour option in the Responses API |
The Claude figures come from Anthropic's prompt caching documentation and the OpenAI figures from OpenAI's prompt caching guide, both checked in November 2026. On both, the write rate replaces the normal input rate for those tokens rather than being added on top. One OpenAI detail catches people out: on GPT-6.2 and later, top level instructions in the Responses API are appended after the input and billed at the uncached rate on every call, so reusable instructions belong in the first developer message instead.
A worked example
Take a support assistant with a 20,000 token system prompt holding the product manual, answering 1,000 questions a day. Assume, for round numbers, a model that charges 3 US dollars per million input tokens.
- Without caching: 20 million prefix tokens a day at full price is 60 dollars a day.
- With a 5 minute Claude cache and steady traffic: the first call in each window pays 1.25 times to write, later calls pay 0.1 times to read. If questions arrive often enough to keep the cache warm, nearly every call is a read, and the prefix cost falls to roughly 6 to 7 dollars a day.
That is close to a 90 percent cut on the repeated part. The question tokens and the output tokens are billed normally, so the total bill falls by less, usually a lot less if answers are long. Our AI cost calculator lets you run your own numbers.
When it pays off, and when it does not
| Good fit | Poor fit |
|---|---|
| Long system prompts reused on every call | Short prompts below the minimum length |
| Chat with a large document or codebase | Prompts that change near the start every time |
| Agents that loop with the same tool definitions | Traffic so sparse the cache expires between calls |
| Long multi turn conversations | Workloads where output tokens are most of the bill |
The most common reason caching fails silently is a timestamp, user name or random ID placed near the top of the prompt. One changed character early in the prefix and nothing after it matches. Move anything dynamic to the end.
Does prompt caching reduce quality?
No. Anthropic states that caching has no effect on output generation, and the response is the same as it would be without the cache. The model sees exactly the same input. The provider only skips recomputing a part it has already processed.
Does it happen automatically?
On OpenAI, yes: caching is on by default for supported models once a prompt passes the minimum length, and you can add explicit breakpoints to control where writes end. On Claude you mark what to cache, or turn on automatic caching, and Claude Managed Agents cache by default. Claude Code relies on caching heavily, which is part of why long coding sessions cost less than the raw token count suggests.
Is prompt caching the same as KV caching?
They are related. A KV cache stores the attention keys and values a model computes while it reads a prompt, so it does not redo that work as it generates each new token. That happens inside a single request on every model. Prompt caching keeps that kind of computed state across separate requests, so a later call can reuse it. You control prompt caching through the API. KV caching within a request is automatic and invisible.
How it fits with other savings
Caching stacks with batch discounts, model routing and shorter prompts. If your bill is growing, our guides on reducing AI API costs and what drives your AI API bill cover the rest, and the per model prices are in our Claude API pricing guide.
Saraswati Stitch®