Why an unchanged prefix can miss
Cache entries are not guaranteed to remain available for every request. Scaling, capacity changes, failover, deployment updates, or eviction can cause an unchanged prefix to be processed again. Routing hints such asprompt_cache_key and x-abliteration-session-id improve the chance that related requests reuse cached work. They do not reserve cache capacity or guarantee a cache hit.
What must match
Caching operates on the rendered token prefix, not only the visible user message. A reusable prefix generally requires:- the same project and model,
- identical system and developer instructions,
- identical earlier messages in the same order,
- identical tool definitions and tool ordering,
- compatible reasoning, output-format, and multimodal settings, and
- enough unchanged tokens to form reusable cache blocks.
Understand cache usage and billing
Cache usage is measured independently for each API request. A growing conversation does not mean the cached-token count must increase on every request.
One request can include both cache reads and cache writes. A cache write does not promise that a later request will read those tokens.
Improve cache reuse
Place stable content first and variable content last. Keep system instructions, tool definitions, and their ordering consistent between requests. Use one stable, opaque affinity value for each logical conversation or reusable workload. Do not use one global value for unrelated traffic, and do not put prompts, personal data, or secrets in the value. For Chat Completions and Responses, setprompt_cache_key. This Chat Completions example uses one key for a conversation:
x-abliteration-session-id: conv_7d2a9f.
If both values are present, x-abliteration-session-id is used as the routing hint. For parallel workloads, let the first request begin returning output before sending the remaining requests so a reusable entry has time to be created.
Agent clients
Agent clients such as Claude Code can send several API requests for one visible turn, including tool-use continuations, retries, and conversation compaction. Usage and request counts are recorded per API request, not per visible turn. Compaction changes conversation history and can reduce cache reuse. For Claude Code,CLAUDE_CODE_ATTRIBUTION_HEADER=0 is not required for prompt caching on abliteration.ai.
Cache controls and retention
abliteration.ai does not promise a fixed cache-retention window. Entries can be evicted or become unavailable before a later request arrives.- OpenAI-compatible
prompt_cache_retentionis not supported. - Claude Code’s
ENABLE_PROMPT_CACHING_1Hflag does not extend or guarantee cache retention on abliteration.ai. - On
/v1/messages, supported Anthropic-stylecache_controlobjects are accepted for SDK compatibility, but caching remains automatic. Attlvalue does not reserve an entry or guarantee that it remains available for that duration on abliteration.ai.
Check cache usage
Treat the response usage as the source of truth. A positive cached-token count confirms the tokens actually read from cache.
For a streaming request, inspect the final usage event or chunk. On Chat Completions, set
stream_options: { "include_usage": true } to receive the usage chunk.
A reported cache-read count of zero means no tokens received the cache-read discount for that request. If usage is absent, inspect the final usage-bearing streaming event or the dashboard instead of inferring a miss. A cache miss is normal; the affected input tokens are billed at the standard input rate and processed again rather than reused.