Dev Practice

Check minimum tokens and 5-minute TTL before connecting Claude prompt caching to production APIs

Key Takeaway

Claude prompt caching keeps system prompts in API memory for 5 minutes. Reads receive a 90% discount, while writes cost 125%. Check your token counts against minimum model thresholds before implementation.

A sage green ceramic mug on a linen coaster, a closed blank notebook with a wooden pen, and a small potted plant on a sunlit oak desk by a window with sheer linen curtains

What is the minimum token threshold required for prompt caching?

According to the prompt caching documentation, not every request creates a cache entry. Minimum token boundaries depend on the model family.

Claude 3.5 Sonnet and Claude 3 Opus require at least 1,024 cumulative tokens from the start of the prompt to the cache breakpoint. For Claude 3.5 Haiku, the minimum threshold is 2,048 tokens. If you apply cache parameters to prompts shorter than these limits, the API executes without error, but no cache is stored and standard input token rates apply to each call.

Short system prompts or brief one-off queries do not benefit from caching. Consider caching when your requests contain stable contexts exceeding 1,024 tokens, such as multi-page technical manuals, extensive function tool definitions, or multi-turn conversational histories.

How are cache write and read costs calculated?

As outlined in the models and pricing documentation, prompt caching rates are calculated relative to standard input token prices. Cache creation write rates and subsequent cache hit read rates are priced differently.

CategoryApplied rateTTL refreshCharacteristics
Base input token100%Not applicableBilled when caching is inactive or prompt is below minimum threshold
Cache write125%5 minutes startsCharged when writing the initial cache block into server memory
Cache read10%5 minutes extended90% discount applied on matching prefix requests within 5 minutes

The source is the Anthropic official pricing documentation, checked on October 25, 2026.

Because cache writes cost 25% more than standard input tokens, you need at least two cache read requests within the 5-minute TTL window to see actual cost savings. If a cached block is queried only once before expiration, the overall request costs 25% more than a standard non-cached API call.

How do you specify cache breakpoints in request payloads?

To activate prompt caching, place the cache_control property inside specific payload blocks. The currently supported structure is {"type": "ephemeral"}.

In the Python SDK repository examples, you can supply system parameters as an array of content blocks and attach cache control to the end of a block. For large tool definitions, you can append cache control to the final entry in the tools array. Up to four cache breakpoints can be defined within a single request.

Caches match only when prefix bytes match identically from the beginning of the prompt. If you insert variable timestamps or random request UUIDs at the top of a system prompt, the cache key changes on every call, preventing cache hits. Place fixed instructions and guidelines first, and push dynamic user inputs and variables toward the end of the prompt.

Which production traffic patterns risk increasing expenses?

Depending on how your service sends requests, introducing caching can unexpectedly increase infrastructure costs. Review your traffic characteristics before updating production code:

  1. Intermittent batch workloads with intervals exceeding 5 minutes: In cron schedules running every 10 minutes, the cache expires between runs, repeatedly triggering the 125% write charge.
  2. Architecture with per-user dynamic system prompts: Placing user IDs or personalized variables at the prompt prefix prevents shared cache creation across users, degrading hit rates.
  3. Prompts fluctuating near the 1,024-token boundary: Minor text length variations may cause some requests to fall to 1,020 tokens (bypassing cache) and others to reach 1,030 tokens (incurring write costs).
  4. Dynamic model routing: Caches are maintained independently per model ID. Toggling between Sonnet and Haiku with identical prompts does not share cached blocks.

These checkpoints serve as technical guidance for architectural evaluation. Analyze peak traffic windows and user interaction intervals to selectively enable caching on paths generating frequent requests within 5 minutes.

What should you monitor in logs and SDK responses before rollout?

After configuring cache parameters, log the usage object returned by the API response. Anthropic API responses include three token count metrics to reflect cache behavior.

First is cache_creation_input_tokens. A value greater than zero indicates that a new cache block was generated during this request. Second is cache_read_input_tokens. This number must rise to confirm that the 90% discounted read rate is actively applied. Third is standard input_tokens, which records any remaining uncached tokens in the request.

During early deployment, track cache hit rates by calculating the ratio of cache_read_input_tokens against total input tokens. If an endpoint registers cache writes without corresponding read hits, remove the cache_control configuration from that request path. The official documentation was verified on October 25, 2026.

Frequently Asked Questions

Does adding cache_control to every prompt always reduce costs?

No. Writing to the cache costs 125% of the base input rate. If a cached block is read fewer than twice within its 5-minute TTL, or if prompt tokens fall below the minimum threshold, total costs may rise or standard input rates will apply.

Is the 5-minute cache TTL fixed from the initial creation time?

No. Each cache hit resets the 5-minute TTL. Continuous requests within 5-minute windows keep the cache active without expiration.

Do you need a separate endpoint URL to use prompt caching?

No. You use the standard Messages API endpoint (/v1/messages). Simply place the cache_control property inside request content blocks and supply the required beta header.

Sources & Verification Date

  1. Prompt caching (Anthropic Docs) · Verified
  2. Models and pricing (Anthropic Docs) · Verified
  3. Anthropic Python SDK (GitHub Repository) · Verified

All materials have been verified from official announcements and may have changed since verification.