Prompt Caching
An inference optimization mechanism in large language model APIs that reuses the KV Cache of unchanged prefix portions—such as system prompts and tool definitions—across multi-turn conversations on the server side, avoiding redundant computation and thereby reducing latency and API call costs.
Core Facts
Common context pruning strategies include sliding window (retaining the most recent N messages), summary compression (summarizing old messages into a summary), and importance filtering (prioritizing the retention of tool call results).
Token caching (Prompt Caching) is a cost-optimization mechanism in large model APIs; when the same prefix appears repeatedly across multiple requests, the computation result can be cached and charged at a lower rate.
The core principle of prompt caching is cross-request reuse of the KV Cache, where already-computed KV states can be cached and reused when multiple requests share the same prefix.
Timeline (last 90 days)
Claude API prompt caching works by "prefix matching" and requires developers to explicitly mark the cached content.
On a prompt cache hit, first-token latency and input token billing both drop significantly; on a miss, it is equivalent to an ordinary request.
Mainstream prompt caching implementations typically require the cached prefix to be byte-for-byte identical and valid within a certain time window.
Prompt caching is a technique for optimizing inference costs: when multiple requests contain the same prefix, the inference provider can cache that portion of the computation and reuse it directly in subsequent requests, thereby reducing redundant computation.
Cache hit rate (prompt caching) refers to the mechanism in AI APIs whereby repeatedly appearing prefix content is cached, and subsequent requests that hit the same prefix are billed at a lower price and responded to faster.
The prompt caching mechanism allows the server to reuse the intermediate state of shared prefix content, charging a price far below standard input for these tokens.
Prompt caching only changes the billing price, not the capacity limit of the context window; the sum of all counts (including cache reads and writes) is still subject to the window limit.
A prefix cache entry is only available after the first response begins; 100 parallel requests with the same prefix sent at the same time may all write and each pay the write price, and the correct approach is to send one first, wait for its response to begin, then send the rest.
Taking Sonnet 5.5 as an example, an uncached request costs 1 unit, while with 5-minute caching a write of 1.25 plus a read of 0.05 equals 1.3, so it breaks even on the second request within the lifetime; 1-hour caching only wins with at least three requests within the window.
When the prefix is shorter than the model's minimum cacheable length, it is silently treated as uncached without an error, and the minimum value varies from 512 to 4096 tokens across models.
40 more timeline events
All Facts (20)
Common context pruning strategies include sliding window (retaining the most recent N messages), summary compression (summarizing old messages into a summary), and importance filtering (prioritizing the retention of tool call results).
90%VerifiedToken caching (Prompt Caching) is a cost-optimization mechanism in large model APIs; when the same prefix appears repeatedly across multiple requests, the computation result can be cached and charged at a lower rate.
80%VerifiedThe core principle of prompt caching is cross-request reuse of the KV Cache, where already-computed KV states can be cached and reused when multiple requests share the same prefix.
80%VerifiedPrompt caching is a capability of the Anthropic API: when the prefix portion of a request is exactly identical to the previous request, the server can reuse the already-computed intermediate state and skip redundant prefill computation.
75%VerifiedThe higher the cache hit rate, the closer the actual billing is to the cache price rather than the full input price, which can reduce costs by an order of magnitude.
75%VerifiedThe KV Cache mechanism avoids repeated computation of historical tokens, but its memory usage grows linearly with context length.
75%VerifiedThe general principle for achieving cache hits is to keep the prefix of the request context as stable as possible, placing fixed content such as system prompts and tool definitions at the very front, with per-turn user input appended at the end.
75%VerifiedThe caching mechanism is technically commonly referred to as KV Cache or Prompt Caching
70%VerifiedPrompt caching means the identical prefix shared by multiple requests is fully billed and processed only on the first request, and subsequent requests hitting the cache can lower the input token price and reduce latency; but caching cannot shorten the total context length, and long histories still occupy the context window and raise latency.
65%VerifiedCached input tokens are a discount mechanism offered by providers such as OpenAI for large repeated prefixes (such as system prompts, long documents, and few-shot examples); input tokens that hit the cache are billed at a lower rate, usually only about one-tenth of the standard input price.
65%VerifiedPrompt cache validity typically ranges from only a few minutes to several hours, and discount rates and cache windows may be adjusted at any time.
65%VerifiedCache entries have a validity period of approximately 5 minutes (default) to 1 hour (extendable), after which they are treated as cache misses.
65%VerifiedPrompt caching saves pre-computed KV matrices on the server side, reducing the processing of repeated prefixes from O(n²) to O(1) cache reads, enabling up to 90% compression in latency and cost.
65%Partially VerifiedCache hit rate (prompt caching) refers to the mechanism in AI APIs whereby repeatedly appearing prefix content is cached, and subsequent requests that hit the same prefix are billed at a lower price and responded to faster.
75%UnverifiedWhen developers adjust the schema of structured output, the new version can retain previous reasoning content and reuse the prompt cache.
70%UnverifiedAnthropic's prompt caching is divided into two write durations, 5 minutes and 1 hour, with different write prices, while the read price is uniform and far lower than the regular input price.
60%UnverifiedPrompt caching allows vendors to cache the same repeated prefix in an Agent loop, with subsequent calls billed at the cache read price, in this example $0.20 versus $4 for input, 20 times cheaper.
60%UnverifiedPrefix caching is extremely sensitive to input stability; as long as any single token in the prefix is modified or inserted, the cache is invalidated and all subsequent content must be recomputed.
60%UnverifiedClaude API prompt caching works by "prefix matching" and requires developers to explicitly mark the cached content.
50%UnverifiedMainstream prompt caching implementations typically require the cached prefix to be byte-for-byte identical and valid within a certain time window.
50%