Activation
Caching is opt-in and never enabled automatically. You control it per-request via an HTTP header.Custom TTL
By default, cached responses are kept for 7 days. Override with theCache-Control header:
Code examples
Force refresh
Custom TTL (1 hour)
How cache matching works
Cache key
The cache key is a SHA-256 hash of:max_tokens, temperature, stream, or any other parameter.
Storage
Responses are stored in Redis (Upstash, EU West — Ireland). Streamed responses are stored chunk by chunk and replayed as a real stream on a cache hit — your code does not need to handle two different response modes.Use cases
What benefits from caching
FAQ bots and automated support When multiple users ask the same question, the provider is called only once. The second user (and every subsequent one) gets the cached response instantly.What caching doesn’t cover
Conversations with history In a chat, each request includes the full conversation history. Themessages[] array grows with every exchange — the hash is different each time, so cache hits are not possible.
Templates with variable content
If your prompt changes on every call (summarizing different documents, analyzing different products), the hash will differ each time.