API Support
Just set thecache_control param in your respective message body:
Cache TTL Options
By default, the cache has a 5-minute lifetime that refreshes each time cached content is used. You can optionally specify a 1-hour TTL by adding thettl field to cache_control:
Cache reads cost 0.1x the base input token price regardless of TTL.
- The message you are caching needs to cross minimum length to enable this feature (1024 tokens for Claude 3.5 Sonnet and Claude 3 Opus, 2048 tokens for Claude 3 Haiku)
- You can mix both TTLs in the same request, but 1-hour entries must appear before 5-minute entries
- Up to 4 cache breakpoints per request
Automatic Caching
Instead of marking individual messages, you can have the gateway turn on Anthropic’s automatic caching for every request by settingauto_caching to true in your Config:
cache_control: { "type": "ephemeral" } to the request. A cache_control you set on the request yourself is kept as is. auto_caching is inherited by nested targets and can be overridden on a target. It applies to Claude models on Anthropic, Google Vertex AI, Azure AI Foundry, and Claude Platform on AWS for /chat/completions and /messages, including requests to the Responses API (/v1/responses) that are sent to Claude. It also applies to /messages on Amazon Bedrock (InvokeModel) and Bedrock Mantle (anthropic.* models only). Bedrock Converse is not covered.
Seeing Cache Results in Prisma AIRS AI Gateway
The AI Gateway automatically calculates the correct pricing for your prompt caching requests & responses based on Anthropic’s calculations here: In the individual log for any request, you can also see the exact status of your request and verify if it was cached, or delivered from cache with twousage parameters:
cache_creation_input_tokens: Number of tokens written to the cache when creating a new entry.cache_read_input_tokens: Number of tokens retrieved from the cache for this request.
Understanding Token Counts with CachingThe AI Gateway normalizes Anthropic’s response to the OpenAI format. In this format, This differs from Anthropic’s native format where
prompt_tokens includes the cached tokens:inputTokens excludes cached tokens. The AI Gateway’s pricing calculation accounts for this by:- Subtracting cached tokens from
prompt_tokensto get the base input token count - Applying the standard input token rate to base tokens
- Applying the discounted cache read rate to
cache_read_input_tokens - Applying the cache write rate to
cache_creation_input_tokens

