Quality, latency, cost: the AI trade-off triangle

In one sentence

Every AI design choice trades quality, latency and cost, plus risk. Set a bar for each, know which lever moves which corner, and pick from the measured Pareto frontier instead of arguing.

Analogy: Shipping parcels: overnight is fast and pricey, ground is cheap and slow. A sensible company picks per parcel based on what it's worth, not one service for everything.

Decide with measurements: evaluate candidates on one eval set, keep the frontier, ship the cheapest config that clears every bar.

How it works

  • You rarely improve one corner for free: hit the bar on two and optimize the third.
  • Bigger models, more reasoning effort and reranking buy quality, paid in dollars, tokens and latency.
  • Caching cuts cost and latency with almost no quality loss; batching is ~50% cheaper but takes hours.
  • Run one eval set over candidate configs and keep the Pareto frontier: configs nothing beats on every axis.
  • Present the frontier as a menu, so product picks the trade-off with data, not opinions.

Check yourself

Answer to mark it learned; your answers aren't scored.

A backend service calls your LLM endpoint and waits for the complete JSON; p95 is over budget. Requests carry ~3k prompt tokens, and half of each output is an explanation field the service discards. Which change cuts latency most?

Go deeper

Full explanation

Every AI architecture decision moves you inside a triangle of quality, latency and cost, with risk (safety, compliance, blast radius) as a fourth constraint. You rarely improve one corner for free: hit the bar on two and optimize the third.

The levers, and what they buy:

Measure, don't argue. Run one eval set over candidate configs, record quality, p95 latency and cost, and keep the Pareto frontier: configs that no other config beats on every axis. Present it as a menu: "Option B: 2 points less quality, 60% cheaper, 1.2 s faster. Which do we want?" That turns a debate into a product decision with data (Communicating trade-offs to executives).

Code Pick the cheapest config that clears quality and p95 bars
pythonPick the cheapest config that clears quality and p95 bars
QUALITY_BAR = 0.85   # pass rate on the golden set
P95_BAR_MS = 2500    # end-to-end latency budget

# One row per config: the same eval set run against each
results = [
    {"config": "large, effort=high, k=20", "quality": 0.91, "p95_ms": 6200, "usd_per_1k": 41.0},
    {"config": "large, effort=low, k=50",  "quality": 0.87, "p95_ms": 3400, "usd_per_1k": 24.0},
    {"config": "large, effort=low, k=20",  "quality": 0.88, "p95_ms": 2900, "usd_per_1k": 18.0},
    {"config": "mid + rerank, k=8",        "quality": 0.87, "p95_ms": 1900, "usd_per_1k": 6.5},
    {"config": "mid, k=8",                 "quality": 0.83, "p95_ms": 1600, "usd_per_1k": 5.9},
    {"config": "small + cache, k=5",       "quality": 0.79, "p95_ms": 700,  "usd_per_1k": 1.2},
]

def dominates(b: dict, a: dict) -> bool:
    """b is no worse than a on every axis and strictly better on one."""
    axes = [(b["quality"], a["quality"]), (-b["p95_ms"], -a["p95_ms"]),
            (-b["usd_per_1k"], -a["usd_per_1k"])]   # higher is better after sign flip
    return all(x >= y for x, y in axes) and any(x > y for x, y in axes)

frontier = [a for a in results if not any(dominates(b, a) for b in results)]
passing = [r for r in frontier
           if r["quality"] >= QUALITY_BAR and r["p95_ms"] <= P95_BAR_MS]

if passing:
    best = min(passing, key=lambda r: r["usd_per_1k"])
    print("ship:", best["config"])          # -> mid + rerank, k=8
else:
    print("no config clears the bars; frontier:", [r["config"] for r in frontier])
Real example

Product asks for "the best model, fast and cheap" for support answers. Instead of debating, you run 400 golden questions over six configs. The large model with high reasoning effort scores 91% but has a 6.2 s p95 and costs ~$41 per 1,000 requests. A mid-size model plus a reranker scores 87% at 1.9 s and ~$6.50. Against bars of 85% and 2.5 s, mid + rerank ships, ~84% cheaper than the large one. A classifier sends the hardest ~5% of questions to the large model.

Trade-offs +3 · −3

+ You gain

  • Turns opinion fights into one chart and a data-backed choice.
  • Exposes free wins: configs that are both better and cheaper do exist.
  • Gives stakeholders a menu with explicit costs instead of a single 'best'.

− You pay

  • Needs a trustworthy eval set; a small or noisy one draws a fake frontier.
  • The frontier drifts as prices, models and traffic mix change every few months.
  • Risk and UX don't fit neatly on the chart; judgment is still required.

Use it when

Any model, prompt, retrieval or infra choice with real cost or latency at stake, and whenever someone asks for 'the best model' without naming a budget.

Avoid it when

Early prototypes with tiny traffic: start with a strong model and get quality right; optimize cost once volume and an eval set exist.

Numbers to know 5
  • OpenAI latency guide: halving output tokens can cut latency ~50%; halving the prompt often only ~1–5%.
  • Price spread inside one family: GPT-4.1 $2 vs GPT-4.1-nano $0.10 per 1M input tokens (20×, 2025 list).
  • RouteLLM (2024): ~85% cheaper than GPT-4-only on MT Bench at 95% of its quality.
  • Batch APIs: ~50% off for results within 24 h. Anthropic cached input reads: ~0.1× base price.
  • Nielsen's limits: ~0.1 s feels instant, ~1 s keeps the flow of thought, ~10 s loses attention.
Common pitfalls 4
  • Comparing configs on a few dozen examples: 1–2 point gaps are noise. Report confidence intervals.
  • Optimizing mean latency when users feel p95, p99 and time to first token.
  • Counting only list price per token: retries, reasoning tokens, reranker GPUs and human review cost too.
  • Deciding once: re-run the frontier when a new model ships or prices drop.
Interview questions 3

Answer out loud first, then reveal.

The PM wants the best model, fast and cheap. How do you respond?Show answer

I agree with the goal and make the trade-off explicit. First I ask for bars: what quality is good enough on our eval set, what p95 the UX tolerates, and what a request may cost at projected volume. Then I evaluate several configs on the same golden set and show the Pareto frontier. Usually a mid-size model with better retrieval or routing clears the bar at a fraction of the cost, and only the hard slice goes to the big model. The risk I flag: the frontier is only as good as the eval set.

Which levers do you pull to cut latency without hurting quality?Show answer

In order of safety: stream, so perceived latency drops to TTFT. Cache the static prompt prefix to cut prefill. Shorten outputs, since output tokens dominate generation time. Run independent steps like retrieval and guardrails in parallel. Then route easy requests to a smaller model and lower reasoning effort; those do touch quality, so I verify them on the eval set. If we self-host, quantization and speculative decoding come next. I track p95, never the mean.

How do you present an AI trade-off to executives?Show answer

As a short menu, not a lecture. Two or three options from the frontier, each with quality on our eval set, p95 latency, monthly cost at projected volume and its main risk. Then my recommendation and what would change it, for example: if volume doubles, we switch to routing. Executives decide on business impact, so I translate points of quality into outcomes like resolution rate or escalations avoided.