Skip to content
Inference Academy

Cost and latency budgets for LLM features

Turn a feature into numbers before you build it: tokens per request, calls per request, cost per thousand requests and per month, latency as the sum of sequential calls, prompt caching, routing to a small model, agent cost growth, and a runnable calculator comparing five designs.

By

14 min · verified 2026-11Pro
Share

Most LLM features are approved on a demo and discovered to be too slow or too expensive in production. Both are predictable from a handful of numbers you can estimate before writing code: tokens in, tokens out, number of calls, and whether those calls happen in sequence.

#The two formulas

For one model call:

latency≈TTFT+output tokens÷decode speedcost=(uncached input×input price+cached input×cached price+output×output price)÷1,000,000\begin{aligned} \text{latency} &\approx \text{TTFT} + \text{output tokens} \div \text{decode speed} \\ \text{cost} &= (\text{uncached input} \times \text{input price} + \text{cached input} \times \text{cached price} + \text{output} \times \text{output price}) \div 1{,}000{,}000 \end{aligned}

For a feature, add up the calls that run in sequence for latency, and all calls for cost. Parallel calls add cost but not latency.

Where the numbers come from:

Number How to estimate it
Input tokens Count your prompt parts (context budget)
Output tokens Measure on 50 real examples; reasoning models add thinking tokens
TTFT and decode speed Your server's metrics, or a benchmark at realistic concurrency
Prices Your provider's current price page, or your own cost per token for self-hosting
Calls per request Your design: router, retrieval rewrite, answer, verifier, agent steps

Pro content

Keep reading with Inference Academy Pro

Unlock the rest of this lesson, plus every advanced lesson, hands-on lab, the larger playground models and completion certificates.

Still to come in this lesson

  1. A calculator for five designs
  2. Levers, in rough order of impact
  3. Budgets as guard rails
  4. Reasoning models
  5. Common mistakes
  6. Exercises

You will be able to answer

  • An agent makes five tool-using model calls and one final call, in sequence. How does its latency compare with one call?
  • Why does an agent's cost grow faster than its number of steps?
  • A 3,000-token prompt has a 2,500-token stable prefix. What does prefix caching save?
  • To hit a 3 s p50 with a 0.4 s time to first token and 400 output tokens, what decode speed do you need?
  • What is usually the biggest single lever on cost for a high-volume feature?