AI & Machine Learning

Prompt caching

Also known as: context caching, prompt cache, LLM prompt caching

Prompt caching is a feature of AI APIs that saves the processed version of the beginning of a prompt, such as long instructions, a big document, or tool definitions, so later requests that start the same way don't have to process it again.

Cached input is billed at a steep discount and returns faster. While prompt caching can cut costs dramatically for chatbots and agents, it only works when the repeated part stays exactly the same and comes first.

Prompt caching, explained at three levels

At home

Imagine a teacher who gives every class the same 20-minute safety briefing before a short new lesson. Prompt caching is like recording the briefing once and replaying it instantly, so only the new part takes real effort. AI apps often resend the same long instructions or documents with every question, and caching lets the AI provider skip reprocessing that repeated opening part.

At work

Prompt caching is a feature of AI APIs that stores the processed version of the repeated opening of a prompt, such as system instructions, tool definitions, or a long document. Later requests that start the same way reuse it, so cached input is billed at a steep discount, often 50 to 90 percent off, and responses start faster. For high-volume AI apps, it can cut bills substantially.

Real-world examples

At home

Lena uploaded a 200-page manual to an AI assistant and asked several questions. The first answer took a while, but later ones came back quickly because the manual was cached.

At work

Carlos manages the AI budget at a Toronto software company. Reordering their support bot's prompts so the long policy instructions came first raised cache hits and cut the monthly API bill by more than half.

How it compares

featurePrompt cachingResponse caching
What's reusedProcessed prompt prefixA previous final answer
AnswersFreshly generated each timeIdentical to before
Works whenStart of prompt matchesWhole request matches
Offered byAI providersUsually your own app

Prompt caching saves work but still generates new answers. Response caching reuses the old answer.

For analysts

For any AI feature with long, repeated instructions, I'd ask the team to measure the cache hit rate. It's often the single cheapest optimization available.

History & origin

Language models process every token of a prompt before answering, so long system prompts and documents were paid for again on every request. Google introduced 'context caching' for Gemini in 2024, and Anthropic launched prompt caching for Claude in August 2024, advertising cost reductions of up to 90 percent and lower latency on long prompts. OpenAI added automatic prompt caching in October 2024 with a 50 percent discount on cached input. Caching became especially important for AI coding agents and multi-step agents, which resend large amounts of context on every step. In my view, prompt caching is one of the least glamorous and most valuable cost features in AI, and many teams leave money on the table by ignoring it.