Why Prompt Caching
Reduce Token Costs
Cached prompts are processed at significantly reduced rates by providers (up to 90% savings)
Faster Processing
Providers skip re-processing cached prompt segments for faster response times
Automatic Optimization
Automatic on supported models; some providers require explicit cache directives
OpenAI and Compatible Providers
Caching behavior and minimum prefix lengths depend on the provider and model. Where supported,prompt_cache_key provides a stable routing or reuse hint; it does not guarantee a hit.
Use the provider coverage below to distinguish automatic caching, explicit controls and unverified behavior.
Provider Coverage
Prompt caching is a gateway concern for every client, including coding tools, SDKs and direct HTTP calls. It is separate from Planck’s full-response cache. Planck preserves reported cache usage; it cannot create an upstream cache hit on a model without caching support. Reviewed October 19, 2026 against the provider-key UI, canonical provider registry, generated endpoints and gateway adapters. The catalog contains 21 upstream providers plus Planck and the deprecatedbifrost alias. Together and direct Moonshot are not offered providers in this catalog; model authors served through another provider are not additional direct integrations.
“Both” means BYOK and at least one active PTB endpoint exist in the catalog, not that every model supports PTB or that production credentials are configured. BYOK and PTB use the same provider adapters; credential selection and wallet billing differ.
BYOK and PTB Accounting
BYOK skips Planck wallet debits; the provider bills the customer account. PTB prices reported cache reads/writes using the selected endpoint’s registered rates and finalizes the wallet charge. Missing cache discounts fall back to the ordinary input rate; Planck does not invent a discount because the response reports a hit. A cache price in the registry does not enable caching or prove production hits. Reported cache tokens must not be billed twice as ordinary input. Direct Anthropic usage keeps its disjoint counters internally for billing, while public OpenAI-compatible totals include uncached input, cache reads and cache writes. Claude on Vertex/Bedrock already normalizes these totals in its adapter. This review verifies catalog and adapter behavior with local fixtures. It does not certify production provider credentials, model availability or actual cache hits. To validate a deployment, pin one eligible provider/model, send repeated requests with a stable prefix, separately selectPlanck-Billing-Mode: byok or ptb where supported, and compare final usage, request logs and billing. Do not use Planck’s full-response-cache hits as evidence of upstream prompt caching.
Explicit controls and coding clients
Coding clients use the same gateway paths as SDK calls. Anthropic-stylecache_control is retained on supported Claude routes; providers with automatic caching can work without those hints. Client-specific flags do not enable caching on an unsupported model.
For newer OpenAI/Azure models and supporting OpenRouter routes, use the provider’s prompt_cache_options and text/image prompt_cache_breakpoint fields. For example, mark the stable prefix and keep the changing question after it:
prompt_cache_key, mode: "explicit" and ttl: "5m" or "1h" to open or extend a window. Omit the TTL on ordinary reuse requests. Sending it again incurs another write charge. Gateway meters these writes separately, reserves the requested write tariff for PTB, and does not invent writes from cache misses. Explicit retention requests bypass Planck’s full-response cache so a cached answer cannot swallow the upstream operation.
Google/Vertex BYOK callers may supply cached_content (also cachedContent or extra_body.google.cached_content) for an existing resource accessible to their Google credentials. Planck does not create paid cache resources or let PTB callers reference arbitrary platform-owned resources.
Session-affinity and isolation headers are allowlisted per provider. Header values and PTB prompt-cache keys are scoped to the authenticated organization; BYOK prompt-cache keys retain their supplied value. This scopes the hints, not the upstream provider’s entire automatic cache.
Unsupported explicit retention, isolation and cache-resource controls return a request error instead of disappearing. Cache-only prewarm: true and cache markers on unsupported Responses content types are rejected. Provider model limits still apply. Privacy transformations can also change the prefix: request-scoped PII placeholders are randomized and are not weakened to improve cache hits.
Reading Cache Usage
- Chat Completions returns
usage.prompt_tokens_details.cached_tokensand, when reported,cache_write_tokens. Planck’s existing flat counters remain available. - Responses returns the same information under
usage.input_tokens_details. - Anthropic Messages returns
cache_read_input_tokensandcache_creation_input_tokens. Uncachedinput_tokensexcludes those counts. - Streaming clients must consume the final usage and terminal events. Usage can arrive after the model’s finish-reason chunk.
Quick Start
Pricing
OpenAI pricing varies by model: newer families can charge a premium for cache writes as well as discounting cache reads. Compare both counters using the selected endpoint’s rates; do not assume every write costs the ordinary input rate.Planck Model Registry
View supported models and their caching capabilities
OpenAI Prompt Caching Documentation
Official OpenAI prompt caching guide
Anthropic (Claude)
Anthropic provides advanced caching with cache control breakpoints (up to 4 per request) and TTL control.Using OpenAI SDK with Planck Types
The@inquantum/planck-helpers SDK extends OpenAI types to support Anthropic’s cache control through the OpenAI-compatible interface:
Cache Directives and User Metadata
The direct Anthropic adapter maps the first supplied value below tometadata.user_id. This is user metadata; it does not enable prompt caching. Enable caching with cache_control, and keep the prompt prefix stable across requests.
prompt_cache_keysafety_identifieruser
Planck forwards cache directives on system text, text/image content blocks, and tool definitions to direct Anthropic and OpenRouter routes. The native
/v1/messages mapper also preserves cache directives on tool results. Cache support, minimum prefix length, and TTL availability still depend on the selected model and upstream provider.Coding Clients
OpenCode must send cache directives when using Claude through a generic OpenAI-compatible gateway. In versions that supportcompatibility.cacheFormat, set "cacheFormat": "anthropic" in the model’s compatibility settings. This lets OpenCode mark the stable tools, system prompt, and message prefix. Check the OpenCode model documentation for your installed version’s configuration format.
For Anthropic-native clients, use /v1/messages and put initial instructions in the top-level system field, either as text or text blocks. Newer Claude models also support text-only system messages within the conversation; Planck preserves their position after the conversation begins. Provider-specific beta features and newer content-block types are not implied by this compatibility support.
When that surface routes to an OpenAI-compatible provider, Planck converts streamed function calls into Anthropic tool_use blocks. Fragmented and parallel calls are assembled per tool before emission, preserving IDs, names, JSON inputs and the tool_use stop reason. This enables the client to execute the tools it supplied; it does not add Claude Desktop, Cowork or Claude Code tools to models or clients that do not provide them.
Check usage on consecutive requests with an unchanged, sufficiently long prefix. A first request can write the cache without reading it; later requests may report cache_read_input_tokens on the Anthropic surface or prompt_tokens_details.cached_tokens on the OpenAI-compatible surface. Zero reads on a single short connection test do not establish a caching failure. See Anthropic prompt caching and OpenRouter prompt caching.
Pricing Structure
Anthropic uses a simple multiplier-based pricing model for prompt caching.Key Points
- TTL Options: 5 minutes or 1 hour
- Providers: Available on Anthropic API, Vertex AI, and AWS Bedrock
- Availability: TTL options depend on the selected model and hosting route
- Minimum: Cacheable prefix lengths vary by model
Calculation Example
Learn More
Anthropic Prompt Caching Documentation
Google Gemini
Google uses a multiplier plus storage cost model for context caching.Pricing Structure
Storage Rates:
- Gemini 2.5 Pro: $4.50/MTok/hour
- Gemini 2.5 Flash: $1.00/MTok/hour
- Gemini 2.5 Flash-Lite: $1.00/MTok/hour
Key Points
- TTL: 5 minutes only
- Cache Types: Implicit (automatic) and Explicit (manual)
- Minimum: 1024 tokens (Flash), 2048 tokens (Pro)
- Discount: 75% off input costs for cache reads