Skip to main content
Use prompt caching when the same large context appears across many requests. Mark stable instructions, documents, examples, tool outputs, or tool definitions as cacheable so supported providers can reuse that context on later calls. Prompt caching is different from response caching. Prompt caching still runs inference, but can reduce repeated input processing cost and latency. Response caching returns a previously generated answer for an identical request.
Prompt caching is provider- and model-specific. Unsupported providers ignore cache hints or route without cached pricing. Check the model page pricing table for cache read/write rates.

What to cache

Cache content that stays stable across requests:
  • long system instructions
  • reused RAG documents
  • few-shot examples
  • tool definitions
  • large tool results that are reused in the next turn
Avoid caching content that changes every request, contains short one-off user input, or includes sensitive data that your policy does not allow to be stored by the selected provider.

Cache controls

Phaseo accepts a top-level cache_control compatibility hint on Chat Completions, Responses, and Anthropic Messages requests:
Use ttl: "5m" for short-lived shared context and ttl: "1h" when the provider and model support longer-lived prompt cache entries. A top-level cache control is treated as an automatic/default cache policy by providers that support it. You can also place cache_control directly on supported text, image, tool result, and tool definition blocks for explicit cache breakpoints:
Provider-specific aliases remain supported. For example, you can apply a default Anthropic cache policy through provider_options:
Supported scope values: Per-block cache_control wins over the default policy.

Chat Completions

Use /v1/chat/completions when you are using OpenAI-compatible chat clients.
For OpenAI-routed requests, pass OpenAI cache retention options with the OpenAI-compatible top-level field:
The provider-specific alias is also accepted:

Responses

Use /v1/responses for new OpenAI-compatible text integrations and agent flows.
When you already have a Google Gemini cached content resource, pass it through provider_options.google.cached_content:

Anthropic Messages

Use /v1/messages when your client is Anthropic-compatible.
Anthropic Messages supports cache control on:
  • system text blocks
  • message text and image blocks
  • tool result blocks
  • tool definitions

Usage and pricing fields

When a provider returns cache usage, Phaseo normalizes it into common usage fields. Cache writes are usually more expensive than normal input tokens. Cache reads are usually cheaper. Exact pricing depends on the provider, model, and TTL.

Practical checks

After you add prompt caching:
  1. Send one request to create or warm the cache.
  2. Send a second request with the same cacheable content.
  3. Check the response usage and request details for cached read/write fields.
  4. Compare latency and cost over repeated calls, not just the first call.

Provider affinity

Phaseo uses provider prompt-cache usage as a routing signal by default. Once a provider returns cached input tokens, requests with the same cache key or stable opening context prefer that provider for 15 minutes. This avoids paying another provider to rebuild the same prompt cache. If you include session_id, an observed cache read creates session affinity as well. Phaseo retains that affinity for the active session window while still allowing failover when the provider is unhealthy or no longer policy-eligible. Set provider.cache_aware_routing to false to opt out for one request. Set routing.session_affinity to false when the request carries a session_id but should use only normal context-based routing.
Last modified on August 12, 2026