Skip to main content
Caching can reduce the cost of repeated input, such as a system prompt or reference document. Keep that content at the beginning of the request and put changing content after it. A repeated prefix is eligible for caching, not a guaranteed hit. Most supported providers manage caching automatically. For Anthropic routes, add a cache_control breakpoint:
This demonstrates the request shape. Replace the short reference text with a long reusable prefix: short prompts do not meet the provider’s minimum cache length.

Inspecting cache usage

When a backend reports a cache hit, the response includes: On the OpenAI-shaped APIs, cached tokens are a subset of input tokens; do not add them again. An omitted detail field does not establish that caching is available or unavailable for the model. Request logs expose cachedInputTokens and cacheWriteTokens. Messages also reports writes as cache_creation_input_tokens.

Billing

Cache reads use the model’s cached_input_per_mtok_usd rate. Cache writes can cost more than ordinary input: read cache_write_per_mtok_usd and cache_write_1h_per_mtok_usd in the live catalog. Uncached input uses the normal rate. A first write can make a request more expensive. Compare repeated requests and their actual usage before assuming caching saves money.
The request-level marker places one breakpoint on the last cacheable block and advances with the conversation. It works on Chat Completions, Responses, and Messages.For precise placement, put cache_control on a content part. Any explicit marker takes precedence over the request-level marker:
The prefix through that block is cached. Use the appropriate content-part format for your endpoint. On a Chat Completions tool message, a marker is supported only on its last content part because the whole tool result is cached together.
Anthropic’s default lifetime is five minutes, refreshed on a hit. For a one-hour window, use:
5m and 1h are the accepted TTL values. One-hour writes use the higher published write rate. Choose the window based on how often the prefix is reused.The minimum cacheable prefix length depends on the model and backend. A short prefix can return no cache usage without an error. Prefix changes, including whitespace, can cause a miss. After the cache expires, the next eligible request needs another write.
OpenAI, xAI, DeepSeek, and Google routes can cache implicitly. The Anthropic cache_control extension does not force a cache hit on these routes. Availability, prefix length, and expiry depend on the provider. Inspect reported usage instead of assuming that the second request will be cheaper.