Inference, Serving & Production·Question 37 of 76Intermediate

Prompt caching now has a write price and a choice of lifetimes: 5 minutes or 1 hour on Anthropic, 30 minutes or 12 hours on OpenAI's newest models. Work out the break-even reuse count for an agent that resends a 50K-token prefix, and tell me which TTL and breakpoint placement you would pick and when a cache write never pays for itself.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Write the cost model in units of the base input price. A cache write costs w times base (1.25× for Anthropic's 5-minute TTL and OpenAI's 30-minute lifetime on GPT-5.6 and later, 2× for Anthropic's 1 hour, 2.5× for OpenAI's 12 hours). A read costs r (0.1× on most models, 0.05× or lower on some of the newest). Over N uses of the same prefix inside one lifetime, caching costs w + (N - 1)r against N without it. Break-even is N = (w - r) / (1 - r).

Full worked answer

Write the cost model in units of the base input price. A cache write costs w times base (1.25× for Anthropic's 5-minute TTL and OpenAI's 30-minute lifetime on GPT-5.6 and later, 2× for Anthropic's 1 hour, 2.5× for OpenAI's 12 hours). A read costs r (0.1× on most models, 0.05× or lower on some of the newest). Over N uses of the same prefix inside one lifetime, caching costs w + (N - 1)r against N without it. Break-even is N = (w - r) / (1 - r).

  • 1.25× write, 0.1× read: N ≈ 1.3. The second use already pays.
  • 2× write, 0.1× read: N ≈ 2.1. You need three uses inside the hour.
  • 2.5× write, 0.1× read: N ≈ 2.7. Three uses inside 12 hours.

The 50K agent. Thirty calls per task, illustrative $2 per million input tokens. Uncached: 30 × 50K = 1.5M tokens, $3.00. Cached at the short TTL: one write (62.5K token-equivalents) plus 29 reads (145K) = ~207K, about $0.41, an ~86% saving. In practice the prefix grows each step, so each call reads the old history and writes only the new turn. Put a breakpoint at the end of the latest turn and the write premium lands on a few hundred tokens, not 50K.

Choosing the TTL is about the gap distribution, not the average. Anthropic's 5-minute TTL refreshes on every hit, so a busy agent stays warm indefinitely. What hurts is the long gap: a 20-minute human review step or a slow tool. Pay for the longer TTL only when P(gap > short TTL) × cost of a rewrite exceeds the extra write premium. The 12-hour lifetime suits prefixes shared across many users all day, such as a large product catalogue or tool manual, where three uses are trivial. For one user's prefix it rarely pays.

Breakpoint placement. Stable to volatile: after tools and system prompt, after any large document, at the end of the conversation. OpenAI's explicit mode allows up to four writes per request. Anthropic's automatic mode moves one breakpoint forward as the conversation grows, which is right for chat. Anthropic also lets you pre-warm with max_tokens: 0 when a user opens a document, taking the write off the critical path at the price of paying for it even if they never ask.

When a write never pays:

  • The prefix is unique per request, such as a timestamp or request ID near the top.
  • Gaps always exceed the TTL. Every call is then a write at 1.25× or more, worse than no caching.
  • Parallel fan-out fires all requests before the first write lands, so each one writes. Send one, then fan out.
  • The prefix is below the minimum (1,024 tokens on OpenAI, 512 on Anthropic's 5.x models).
  • Calls on different speed tiers or providers do not share cache entries.

Verify with the usage fields (cached versus written tokens) and the providers' cache diagnostics, and track the effective input multiplier per feature.

What a good answer covers

  • Write the cost model in units of the base input price
  • A cache write costs w times base (1.25× for Anthropic's 5-minute TTL and OpenAI's 30-minute lifetime on…
  • A read costs r (0.1× on most models, 0.05× or lower on some of the newest)
  • Over N uses of the same prefix inside one lifetime, caching costs w + (N - 1)r against N without it
  • Break-even is N = (w - r) / (1 - r)

Key terms: The 50K agent · Breakpoint placement · When a write never pays

Interviewer follow-ups to expect

  1. How does a 2,000-token tool-definition change mid-session affect the bill?

  2. Your hit rate is 30% though every prefix is identical: what do you check first?

  3. When would you rather summarise history than cache it?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep