Lesson 1.6
Cost, Latency and Quality Trade-offs
The levers an architect has over cost, latency and quality in a Claude system, the order in which to pull them, and how to reason about cost per completed task rather than cost per request.
Every production conversation about Claude eventually arrives at a triangle: faster, cheaper, better. The professional exam expects you to know the levers, their side effects and the order in which to use them. It also expects you to resist the instinct to reach for a smaller model first.
How cost actually accrues
Cost is driven by tokens, and tokens are not symmetric. Output tokens cost several times more than input tokens. Cached input tokens are read at a steep discount but written at a premium. Tool results and retrieved documents count as input on every subsequent turn. In an agent loop, the whole history is resent each iteration, so cost grows roughly with the square of the number of turns unless caching absorbs the repeated prefix. Current per-token prices by model are in the Anthropic pricing docs; the ratios above are what matter for design.
The right unit of measurement is cost per completed task. A cheaper model that needs two retries, or an agent that takes twice the turns, costs more than the expensive model that got it right first time.
How latency actually accrues
Two numbers matter: time to first token (TTFT), which users perceive as responsiveness, and total generation time, which scales with output length. Thinking adds to TTFT because reasoning happens before the visible answer. Tool calls add round trips. In agents, latency is the sum across turns, which is why interactive products put agents in the background and stream progress.
The levers
| Lever | Cost | Latency | Quality | Notes |
|---|---|---|---|---|
| Prompt caching | Down sharply on repeated prefixes | Down (cached prefix processes faster) | Neutral | The first lever; nearly free quality-wise |
| Shorter, cleaner context | Down | Down | Often up | Remove stale tool results; context editing |
| Output length control | Down | Down | Neutral if instructed well | Ask for the format you need, nothing more |
| Effort setting | Down at lower effort | Down | Down on hard tasks, flat on easy ones | Tune per route, measure with evals |
| Adaptive thinking | Variable | Up on hard problems | Up on reasoning tasks | Model decides when to think; see docs for configuration by model |
| Model tier | Down with smaller tier | Down | Down, task-dependent | Decide with evals, never by assumption |
| Message Batches | Down significantly | Up (asynchronous, hours) | Neutral | For anything not interactive |
| Streaming | Neutral | Perceived TTFT down | Neutral | Mandatory for interactive UX |
| Parallel tool calls | Neutral | Down | Neutral | Return all results in one message |
| Model routing | Down on easy traffic | Down on easy traffic | Preserved if router is accurate | Router errors are a quality risk |
| Priority or fast-mode capacity | Up | Down or more predictable | Neutral | Paid options; availability per docs |
The order of operations
- Fix the quality bar first. Build an evaluation set that defines "good enough" for the task. Without it every cost decision is a guess.
- Establish a baseline with the most capable model at default settings. This tells you what is achievable.
- Take the free wins. Caching, input hygiene (no timestamps or request IDs in the cached prefix, deterministic tool ordering), output hygiene (no verbose preambles), batching for offline work. These rarely cost quality.
- Then trade. Lower effort on routine routes, smaller models on simple traffic, routing between tiers. Each step is validated against the eval set.
- Measure in production. Log tokens, cache hit rates, latency percentiles and task success per route, and revisit when models or prompts change.
Anthropic's guidance notes that on recent models a lower effort setting on a more capable model often matches or beats a previous-generation model at high effort, and keeps you in a single cache namespace. Measure that option before building a multi-model cascade.
Caching as an architectural decision
Caching is a prefix match. The request is rendered as tools, then system, then messages, and any byte change invalidates everything after it. This means the architecture, not just the prompt, determines your hit rate: a gateway that assembles prompts in a stable order, pins tool definitions, and places volatile content last will cache well; one that interpolates the current time into the system prompt will never hit. Verify with the cache read and write counts in the usage object; a zero read count on repeated traffic means a silent invalidator.
Quality is the constraint, not a lever
Treat quality as the constraint you optimise cost and latency against. The failure mode to avoid is quietly accepting a quality regression because the dashboard shows savings. Tie every cost change to an eval run and a production quality metric, and give product owners a veto.
Worked example
A support summarisation route costs more than expected. Investigation shows a 6,000-token system prompt rebuilt with a timestamp on every call, so caching never engages. Fixing the prefix cuts input cost by most of the prompt's share. Next, evals show a lower effort setting holds quality for 90% of tickets; a small classifier routes the hardest 10% to the full setting. Only then is a smaller model trialled, and it fails the eval on multilingual tickets, so it is rejected. Cost falls by more than half with no measured quality loss, and the decisions are documented.
Exam focus
- Output tokens cost more than input tokens; cached reads are cheap, cache writes are a premium; agent loops resend history each turn.
- Cost per completed task, not per request, is the correct metric.
- Order of operations: define quality via evals, baseline with the best model, take free wins (caching, hygiene, batching), then trade effort and model tier.
- Caching is a prefix match rendered tools, system, messages; volatile content must come last; verify hit rates via usage fields.
- Streaming improves perceived latency; thinking and tool round trips increase it; batches trade latency for cost.
- Lower effort on a capable model is often a better first trade than switching to a smaller model.
Check yourself
5 questions
1.A support assistant's monthly API bill has doubled while traffic grew only 20%. Each request carries a 12,000-token system prompt and tool definitions, and the team recently added a 'current time' header at the top of the system prompt. Quality is fine. What should the architect recommend FIRST?
2.Users of a customer-facing chat application report that the assistant 'feels slow', even though total response time is comparable to competitors. Responses are typically several paragraphs and are shown only when fully generated. Which change MOST improves perceived latency at the lowest cost?
3.To cut costs, a team proposes a cascade: send every request first to a small model, then re-send to a large model if a classifier judges the answer weak. Their current design uses one capable model with a large cached prefix. Which consideration should MOST influence the architect's assessment of the proposal?
4.Two configurations of a coding agent are compared on a benchmark of 200 tasks. Configuration A uses a cheaper model: average cost per API request is 40% lower, but tasks take on average 2.3 times as many turns and 18% of tasks fail and are retried by a human. Configuration B uses a more capable model with fewer turns and a 4% failure rate. Finance prefers A because the per-request cost is lower. What should the architect argue?
5.A retailer is launching a Claude-powered shopping assistant for a peak sales event expected to generate twenty times normal traffic for six hours. Load testing shows that above a certain request rate the application receives rate-limit errors and users see failures. The launch is in three weeks. Which combination of actions is MOST appropriate?
