Cost & Latency Tradeoffs
- The cost/quality/speed triangle — why you can never max all three at once
- The six biggest levers to spend where it matters and save everywhere else
- How a cheap-first cascade routes 90% of volume to a small model and cuts cost ~70% without dropping quality on the hard cases
- The latency-specific wins (streaming, parallelism, caching, async) that reshape perceived speed
- Why 'optimize blind' burns quality — measure first, guard with evals second
Quality, cost, and speed pull against each other. You can't max all three at once — but you can spend each where it matters and save everywhere else.
The triangle
A bigger model is smarter but slower and pricier; a smaller one is fast and cheap but less capable. Good engineering is routing each task to the right point on this triangle.
The biggest levers (roughly in order)
- Don't run Opus for classification. Start with Sonnet, drop to Haiku for simple/high-volume steps, reserve Opus for the hard parts. Biggest single lever — see /docs/api/choosing-a-model.
- Use a cheap model first; escalate to a stronger one only when needed (e.g. low-confidence cases). See the worked example below.
- Reuse a stable prompt prefix across calls — big savings for repeated system prompts, RAG context, or agent tool catalogs. See /docs/api/prompt-caching.
- Send only what matters. RAG beats stuffing the whole knowledge base. Shorter inputs = cheaper AND often better output.
- Set sensible max_tokens and tight format instructions. Output tokens are billed at the highest rate — capping them cuts the tail.
- For anything that doesn't need to be interactive, use the Message Batches API. Trades latency for a large per-token discount.
Worked example: a cheap-first cascade
Cascading is the lever people skip because it sounds vague. Make it concrete. Say you need to triage 100,000 support emails. The naive approach runs every email through your strongest model. A cascade routes most of the volume to a cheap model and escalates only the hard cases:
Suppose the cheap model resolves 90% of cases on its own and a stronger model costs roughly 5× as much per token. Counting in relative cost units (1 = one cheap pass over one email):
- All-strong:
100k × 5 = 500kcost units. - Cascade:
100k × 1(every email gets the cheap pass)+ 10k × 5(the 10% that escalate)= 150kcost units.
That's about a 70% cut, and the genuinely hard cases still get your best model. The multipliers and split are illustrative — plug in your own token counts and rates and measure the real escalation rate with evals. The lesson holds regardless: the savings come from how rarely you pay the expensive rate, not from the rate itself.
Latency-specific wins
- Stream responses — users see the first tokens instantly, so perceived speed jumps even when total time is unchanged (/docs/api/streaming).
- Parallelize independent sub-calls — a request that fans out to three tools finishes in max(latency), not sum(latency).
- Cache repeated work and precompute where you can — the fastest tokens are the ones you don't have to generate.
- Pick a smaller model for the interactive path; move heavy lifting async so the user isn't waiting on it.
- Reduce max output tokens for interactive endpoints — long generations are the dominant tail-latency source.
Don't optimize blind
Measure first: where are the tokens and the seconds actually going? Then optimize the biggest line item. And re-check quality with evals after any cost cut — a cheaper setup that's wrong isn't cheaper.
Check yourself
0/4- The triangle is real: quality, cost, and speed pull against each other — engineering means routing each task to the right point, not maxing all three.
- Right-sizing the model is the biggest single lever; cascades multiply it by only paying flagship rates on the hard minority.
- Prompt caching, tight max_tokens, and RAG-driven input trimming compound with model choice.
- Latency-perception is a separate axis — streaming, parallel sub-calls, and async heavy lifting reshape UX without changing raw cost.
- Every cost cut must be guarded by evals — a cheaper setup that's wrong isn't cheaper.