This page is about Anthropic prompt caching. OpenAI and Gemini cache automatically, server-side, at no extra cost and with no flag — there’s nothing to enable. The
cache_control field below is a no-op on those providers, so the same request stays portable across models.Enable it: top-level cache_control
Add a top-level cache_control to the request body. Opper places a single moving breakpoint on the largest cacheable prefix and advances it as the conversation grows — the “automatic” mode, best for multi-turn chats and agent loops.
chat/completions, v1/messages, responses, openresponses, and the Google-shape interactions / generateContent.
Extend the lifetime to 1 hour
Add attl. Useful when your prefix is reused over minutes rather than seconds (a long research session, a slow agent).
Precise placement: per-block cache_control
For fine control over exactly where the cached prefix ends, put cache_control directly on a content block instead of the top level. Anthropic allows up to four such breakpoints. This is the same syntax the Anthropic API uses natively, so existing code works unchanged.
Per-block placement is supported on chat/completions (OpenAI shape) and v1/messages (Anthropic shape):
cache_control and explicit per-block breakpoints, the per-block breakpoints win — Opper won’t add its automatic one on top.
When it’s worth it
Turn it on
A large, stable prefix (system prompt, document, tool catalog) reused across back-to-back calls — agent loops, multi-turn chat, batch jobs over one context.
Leave it off
One-shot calls, or calls spaced further apart than the cache lifetime. You’d pay the 1.25× write premium with no read to recoup it.
cache_creation_input_tokens (written at 1.25×) and cache_read_input_tokens (read at 0.1×). Watch those to confirm caching is paying off — reads should dominate writes once your prefix starts repeating.
Reference
- Field:
cache_control— top-level (automatic) or on a content block (explicit). - Value:
{ "type": "ephemeral" }, optionally"ttl": "1h"(default is 5 minutes). - Activates on: Anthropic-family models. No-op on OpenAI / Gemini (they cache automatically).
- Pricing: cache write 1.25× input, cache read 0.1× input.
- Breakpoints: up to 4 explicit per-block; or 1 automatic top-level.