Prompt caching
If your requests repeat a large unchanging part (a system instruction, tool definitions, a long context), you can cache it. Repeat requests with the same prefix read it from the cache, which is cheaper and faster than processing it again.
Caching is explicit: you turn it on with markers in the request itself. There is no separate flag or parameter for it: the router passes the markers to the provider as is.
Turning it on
Section titled “Turning it on”Mark the block to cache with a cache_control marker in Anthropic format. The marker works on /v1/chat/completions and /v1/messages, in three places: system blocks, tools definitions, and content blocks inside messages.
The ttl field sets how long the cache lives: "5m" (the default) or "1h".
curl https://api.waibee.com/v1/messages \ -H "x-api-key: $WAIBEE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-4.6", "max_tokens": 1024, "system": [ { "type": "text", "text": "<large unchanging instruction or knowledge base>", "cache_control": { "type": "ephemeral", "ttl": "1h" } } ], "messages": [{ "role": "user", "content": "Briefly summarize the main points" }] }'On /v1/chat/completions, put the marker on a content block:
curl https://api.waibee.com/v1/chat/completions \ -H "Authorization: Bearer $WAIBEE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-4.6", "messages": [{ "role": "user", "content": [ { "type": "text", "text": "<large static context>", "cache_control": { "type": "ephemeral" } }, { "type": "text", "text": "Give me a TL;DR" } ] }] }'Which models
Section titled “Which models”Claude models (Anthropic) support explicit caching. To check, look in the catalog: in GET /v1/models, the model’s pricing has input_cache_read and input_cache_write entries, the separate prices for reading and writing the cache. OpenAI models cache a repeated prefix automatically, with no markers, and the result shows up only in usage.
Usage fields
Section titled “Usage fields”Cache hits show up in usage, and the fields depend on the endpoint.
/v1/messages:
"usage": { "input_tokens": 13, "output_tokens": 4, "cache_creation_input_tokens": 8802, "cache_read_input_tokens": 0, "cache_creation": { "ephemeral_1h_input_tokens": 8802, "ephemeral_5m_input_tokens": 0 }}/v1/chat/completions:
"usage": { "prompt_tokens": 8814, "completion_tokens": 4, "prompt_tokens_details": { "cached_tokens": 0, "cache_write_tokens": 8804 }}The first request writes the cache (cache_creation_input_tokens or cache_write_tokens is greater than zero). The next request with the same prefix reads from the cache (cache_read_input_tokens or cached_tokens).
What to keep in mind
Section titled “What to keep in mind”- The prefix must match byte for byte. The beginning of the request up to the marker is cached; put everything that changes after it.
- Lifetime. The cache lives
5mor1hfrom the last access. When it expires or the prefix changes, the cache is written again. - The minimum size and the number of cache points are set by the model’s provider, not by the router: a prefix that is too short is not cached, and the number of
cache_controlmarkers per request is limited. - Autorouting. With the
waibee/automodel, the router tries to keep the same model while the cache is alive. How this works, and which error comes back if no model with caching is found: Autorouting.
Reading from the cache costs less than ordinary input, and writing to the cache costs more. Both prices are in the model’s pricing in the catalog.