Prompt caching

Prompt caching lets an AI service reuse the processed form of a prompt's opening section across requests, so repeated instructions or documents cost less and the answer starts sooner.

Before a large language model writes a word, it has to read the whole prompt and turn every token into internal state. For a short question that is quick. For a prompt that carries a long system prompt, a set of tool definitions or a 100,000-token contract, that reading step is a large part of the time and cost of every request. Prompt caching stores the processed state of the start of a prompt so the next request that begins with exactly the same text can skip that work.

The key word is prefix. A cache hit needs an exact match of everything from the start of the prompt up to a cache point. Anthropic's documentation says caching covers tools, then the system prompt, then messages, in that order, and that changing an earlier part invalidates what follows. OpenAI's guide gives the practical rule: put stable material such as instructions and reference documents first, put timestamps and user-specific details at the end, and append new turns rather than rewriting old ones. A date stamp at the top of a prompt is enough to make every request miss.

The economics differ by provider and change over time. In December 2026 Anthropic's documentation priced a cache write at 1.25 times the normal input rate for the default five-minute lifetime and 2 times for a one-hour lifetime, with cache reads at a tenth of the normal rate by default and lower on some newer models. OpenAI turns caching on by default for supported models, and its guide describes cached reads at a tenth of the input price on most newer models. Google calls the feature context caching and applies it implicitly on Gemini 2.5 and later models. Caches expire, so the saving depends on traffic arriving often enough to keep them warm.

The speed gains can be large. When Anthropic launched the feature in public beta in August 2024, its own test of chatting with a book held in a 100,000-token cached prompt cut the time to first token from 11.5 seconds to 2.4 seconds and the cost by 90%. A ten-turn conversation with a long system prompt saw a smaller cost saving of 53% and a cut in time to first token from about 10 seconds to about 2.5.

Caching does not change what the model says. It is a billing and latency mechanism, not a memory feature: the model does not learn or remember anything between requests, and Anthropic, for one, keeps caches separate between customer organisations. For anyone building coding agents, document assistants or long chats, where most of every request is the same as the last, structuring prompts to hit the cache is one of the simplest ways to cut an AI bill.

Common questions

What is prompt caching in an LLM API?

It is a provider feature that stores the processed version of the opening part of a prompt. When a later request starts with exactly the same text, the model reuses that stored work instead of reading it again, which lowers the input price for that part and shortens the wait for the first token.

Does prompt caching change the model's answers?

No. Anthropic's documentation states that caching does not change output content. The model receives the same input either way; caching only avoids recomputing the part of it that has been seen recently.

How long does a prompt cache last?

It depends on the provider and setting. In December 2026 Anthropic offered a five-minute default that resets on each hit, plus an optional one-hour lifetime at a higher write price. OpenAI's newer models default to a minimum of 30 minutes, with a 12-hour option, and Google describes implicit caches lasting up to 24 hours on a best-effort basis.

Why is my prompt not being cached?

The usual causes are a prompt shorter than the provider's minimum cacheable length, or something near the start of the prompt that changes on every request, such as a timestamp, a user name or a reordered list of tools. Any change before the cache point forces a miss, so stable content must come first.

Finding more

Search for "prompt caching" or "context caching" with a provider's name to find its current rules, since prices, minimum lengths and lifetimes change with new models. The providers' own API documentation is the authority on how their caches behave and what they cost. Engineering write-ups from teams running agents and chat products are useful for prompt layout, but treat claimed savings as specific to their traffic.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.