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 Sandip Maity, Applied AI Engineer
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:
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
- A calculator for five designs
- Levers, in rough order of impact
- Budgets as guard rails
- Reasoning models
- Common mistakes
- 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?