# Prompt caching

> Prompt caching is a provider feature that stores the processed form of a repeated opening section of a prompt, such as long instructions or a reference document, so later requests that reuse it are cheaper and faster.

Also called: context caching, prompt cache, cached tokens, prefix caching. Category: Models and training. Source: https://aibuildindex.com/glossary/prompt-caching

## In the index

- AI API integration: median $2,500, middle half $500 to $6,400, 1,993 priced briefs (https://aibuildindex.com/cost/ai-api-integration)
- Claude: median $3,700, middle half $780 to $9,600, 3,745 priced briefs (https://aibuildindex.com/tools/claude)

Many AI applications send the same large block of text with every request: a long system prompt, a product catalogue, a policy manual or the earlier part of a conversation. Without caching, the model processes and bills that block from scratch each time. Prompt caching lets the provider keep the processed version for a short period, so repeated requests can skip that work. Several major providers offer it, under names such as prompt caching or context caching, with different rules and pricing.

## How it works

Caching works on the prefix, the opening part of a prompt that stays identical between requests. The general pattern is:

1. The first request processes the full prompt and stores the prefix in the cache.
2. Later requests that begin with exactly the same prefix reuse it, and only the new part, such as the user's latest message, is processed fresh.
3. Cached prefixes expire after a period of inactivity, after which the next request rebuilds them.

Providers differ in whether caching is automatic or must be requested, how long entries last, the minimum size that can be cached and how cached tokens are priced. The common thread is that reading from the cache is cheaper than processing the same [tokens](https://aibuildindex.com/glossary/token) again.

Because caching relies on an exact match, prompt order matters. Builds put the fixed parts first (instructions, tool definitions, reference documents) and the changing parts last. A support assistant with a long [system prompt](https://aibuildindex.com/glossary/system-prompt) and a fixed set of policies, for example, can cache that opening block so each customer message only pays full price for the new conversation text.

## What it means for cost

Prompt caching mainly reduces running costs and improves [latency](https://aibuildindex.com/glossary/latency) for applications with large, repeated context and steady traffic. It does little for one-off requests or prompts that change from the start each time. Restructuring prompts to take advantage of it is usually a small piece of engineering with a direct effect on the monthly bill.

When a builder estimates running costs, ask whether caching has been assumed, which parts of the prompt are cacheable, and how traffic patterns affect the hit rate. Estimates that assume caching should also show what happens when the cache expires during quiet periods.

## Common questions

### Does prompt caching change the model's answers?

No. It reuses the processed form of identical input, so the model behaves as if it had read the full prompt. Answers can still vary for the usual reasons, such as [temperature](https://aibuildindex.com/glossary/temperature).

### Is prompt caching the same as caching answers?

No. Answer caching stores a finished response and returns it for identical questions, skipping the model entirely. Prompt caching only speeds up processing of a repeated input; the model still generates a new answer each time.

### Is my data stored when caching is used?

The processed prefix is held by the provider for a limited time to allow reuse. How long and under what terms depends on the provider, so builds handling sensitive data should check the provider's documentation.

## Related terms

- [Token pricing](https://aibuildindex.com/glossary/token-pricing): Token pricing is the usage-based billing model most AI model providers use, charging per number of tokens sent to and generated by the model, usually with separate rates for input and output and different rates for each model.
- [Context window](https://aibuildindex.com/glossary/context-window): A context window is the maximum amount of text, measured in tokens, that a language model can take in and produce in a single request, including instructions, documents, conversation history and its own reply.
- [System prompt](https://aibuildindex.com/glossary/system-prompt): A system prompt is the standing set of instructions sent to a chat-style AI model before any user message, defining its role, rules, tone and limits for every conversation in an application.
- [Latency](https://aibuildindex.com/glossary/latency): Latency is the delay between sending a request to an AI system and receiving its response, which determines whether a feature feels instant, acceptable or too slow for its users.
- [Token](https://aibuildindex.com/glossary/token): A token is the small unit of text, often a word or part of a word, that a language model reads and writes, and the unit that most AI providers use to measure and bill usage.
