Overview
The Context Cache API stores entire message prefixes — such as long system instructions, reference documents, or few-shot examples — so they can be reused across chat-completion requests. When a cache id is supplied, the gateway prepends the cached messages to the request before routing to the runtime, reducing repeated token costs and latency.Base URL
Endpoints
Authentication
All requests require a virtual key in theAuthorization header. See Authentication.
Create a context cache
Request body
Example request
Example response
List context caches
Retrieve a context cache
Delete a context cache
Use a context cache in chat completions
Pass the cache id in thecontext_cache_id field of a chat-completion request. The cached messages are prepended to the request messages before routing.
Cache lifecycle
- Caches are keyed by content hash, so identical messages return the same cache object.
- Caches expire automatically after
ttl_seconds. - Deleting a cache removes it immediately; subsequent requests referencing it return a
404.
Error codes
Related pages
- Chat Completions — use context caches in completions
- Cache — reusable prompt caches for single prompts
- Files — upload documents for retrieval