Automatic Prompt Caching
Automatically injects cache_control into multi-turn calls to Anthropic models, so you get cache discounts with zero setup.
Anthropic prompt caching is opt-in — it only works if you attach cache_control markers yourself, so you miss the discount if you don't know about it. PleumRouter automatically injects cache breakpoints into multi-turn calls routed to Anthropic models — no request changes needed, enabled by default.
curl https://apirouter.pleum.ai/v1/chat/completions \
-H "Authorization: Bearer $PLEUM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [
{"role": "system", "content": "<long system prompt, 4000+ chars>"},
{"role": "user", "content": "First question about the document."},
{"role": "assistant", "content": "..."},
{"role": "user", "content": "Follow-up question."}
]
}'How it decides#
Explicit always wins — if you attached cache_control anywhere in the request yourself, auto-injection backs off entirely. Requests already using explicit caching keep working unchanged.
No-op on the first turn — if the conversation has no assistant message yet (a first request), nothing is injected. It only intervenes on multi-turn conversations, where reuse is certain.
At most 2 injection points — the last block of the system prompt, and the last block of the second-to-last user message (where multi-turn prefix reuse is maximized). Each point is only used when its content totals at least 4,000 characters (matching Anthropic's minimum cacheable size).
Injection happens only inside the request after it is converted to the Anthropic API format, so even if a fallback ends up serving the request from another (OpenAI-compatible) provider, cache_control never leaks there.
Billing and the response#
On a cache hit, the response usage exposes prompt_tokens_details.cached_tokens (hit tokens) and cache_creation_input_tokens (write tokens), and the discount/surcharge is applied to billing automatically. The rates are in the per-provider table below.
"usage": {
"prompt_tokens": 12480,
"completion_tokens": 210,
"prompt_tokens_details": {"cached_tokens": 11900},
"cache_creation_input_tokens": 0
}cache_control explicitly — auto-injection steps aside and only your markers apply.Per-provider behavior#
Automatic cache-breakpoint injection only happens on Anthropic requests converted to the Anthropic Messages format. Other providers such as OpenAI, Google and DeepSeek run their own implicit caching, so no markers are needed. How billing reflects it:
| Provider | Caching | Billing |
|---|---|---|
| Anthropic | Cache breakpoints auto-injected on multi-turn calls (explicit cache_control is passed through) | Read 10% · Write 125% |
| OpenAI · Google · Vertex AI · DeepSeek | Provider-side implicit caching — hit tokens surfaced in usage | Read 10% (DeepSeek 2%) · no write surcharge (OpenAI GPT-5.6 and later models: write 125%) |
| Other OpenAI-compatible | Provider-side implicit caching — hit tokens surfaced in usage | Discounted where a model publishes cache rates, full price otherwise |