Implicit Caching
Implicit caching depends on the model provider. If a provider supports prompt caching, it works automatically on their terms—no configuration required.Provider stickiness: Inworld Router ensures all requests go to the same model provider for a given conversation. If you hit cache with one provider, subsequent requests stay routed to that provider, so you never lose cached data by being switched to a different provider.
Explicit Caching
Explicit caching is supported for Anthropic and Google providers. It gives you control over what gets cached and for how long.Unified Protocol
Both providers use the same protocol: acache_control object in each message content part, including a configurable ttl (time to live).
Cache Control in Messages
Addcache_control to text parts within multipart message content. Reserve it for large bodies of text such as character cards, CSV data, RAG context, or book chapters.
TTL Management
- Configurable TTL: Set
ttlin thecache_controlobject (e.g.,"ttl": "5m","ttl": "1h"). - Update at any time: You can change the TTL on subsequent requests if you originally set it longer than needed.
- Automatic prolongation: When 5% or less of the TTL remains and there are still messages hitting the cache, Inworld Router automatically extends the TTL to keep your cache warm.
User Message Example
Inspecting Cache Usage
To see how much caching saved on each generation, check theprompt_tokens_details object in the usage response.
Request and Response Samples
The following samples were verified against the Inworld Router API. The first request establishes a cache; the second request hits the cache. Request 1 — Cache write (establishing cache)cached_tokens is 1388 and cache_write_tokens is omitted (no write). The cached content is reused, reducing input token cost.
Explicit caching requires a minimum of 1024 tokens in the cacheable content block. Shorter content returns a validation error.
Response Example (summary)
Usage Fields
Some providers charge differently for cache writes vs. reads. Anthropic, for example, charges for cache writes but offers discounts on cache reads. Check provider pricing for details.