Skip to content
Dashboard

Prompt caching across providers: what's automatic, what's explicit, and what it actually saves

Copy link to headingWhat is prompt caching?

Copy link to headingHow prompt caching differs from semantic and response caching

Copy link to headingWhat prompt caching does at the GPU level

Copy link to headingHow providers differ on prompt caching activation and cost

Copy link to headingAutomatic, explicit, and silently broken activation

Copy link to headingRead discounts have converged near 90%

Copy link to headingWrite premiums and the break-even point

Copy link to headingTTLs and minimum-token floors

Copy link to headingHow to keep your prompt cache hit rate high

Copy link to headingMove request-specific content out of the cached prefix

Copy link to headingFreeze tool-definition serialization order

Copy link to headingMatch the TTL tier to your read volume

Copy link to headingInstrument cache reads and writes

Copy link to headingHow Vercel AI SDK and AI Gateway unify prompt caching

Copy link to headingOne providerOptions surface across every provider

import { anthropic } from '@ai-sdk/anthropic';
import { generateText } from 'ai';
const result = await generateText({
model: anthropic('claude-sonnet-5'),
messages: [
{
role: 'system',
content: BIG_SYSTEM_PROMPT,
providerOptions: {
anthropic: { cacheControl: { type: 'ephemeral', ttl: '1h' } },
},
},
{ role: 'user', content: userQuestion },
],
});
// Cache token counts come back on the usage object:
console.log(result.usage.inputTokenDetails.cacheReadTokens);
console.log(result.usage.inputTokenDetails.cacheWriteTokens);

Copy link to headingcaching: 'auto' handles explicit-marker providers for you

const result = await generateText({
model: 'anthropic/claude-sonnet-5',
providerOptions: {
gateway: { caching: 'auto' },
},
messages: [/* system prompt, then user turn */],
});

Copy link to headingSee cache reads and writes per request

Copy link to headingRoute to models that cache automatically

Copy link to headingShip cache-efficient AI apps on Vercel

Copy link to headingFAQs about prompt caching

Copy link to headingDoes routing through AI Gateway reset Anthropic prompt cache hits?

Copy link to headingWhy is my cache hit rate zero even though I set cacheControl to ephemeral?

Copy link to headingDoes OpenAI still cache for free?

Copy link to headingWhat is the difference between prompt caching and semantic caching?

Copy link to headingHow do I monitor cache hit rates through AI Gateway?

Ready to deploy?