Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Counterintuitively, a much LONGER system prompt can drive down cost-per-call below a shorter one. Explain when this flips, and derive the rough hits-per-write threshold above which the verbose-but-cached prompt wins. Be concrete about the discount mechanism on at least one real provider (Anthropic or OpenAI).
A long system prompt costs more on the first call (the cache write) and cheaper on every subsequent hit (the cache read at ~10% on Anthropic, ~50% on OpenAI).
Think of a gym with two memberships. The cheap one charges five dollars every time you walk in. The expensive one charges fifty dollars to sign up, then fifty cents per visit. If you visit once, the cheap one wins. If you visit a hundred times, the expensive one wins by a mile. Long cached prompts are the expensive membership: an upfront premium on the first call, then a tiny per-call charge after. Once you visit (call) enough times, it pays off, and that crossover usually comes after just a few calls because the per-hit discount is so steep.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: name prefix caching, identify write-vs-read pricing tiers, derive break-even N = (L*w - S)/(S - L*r), apply Anthropic and OpenAI numbers to a 5000-vs-500-token example, classify the workload by call rate vs TTL.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating prompt-caching value as a flat discount on every call. The actual structure has a write premium on the first call and a read discount on subsequent hits, and the break-even is amortized over the hit count, not per call.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.