Topic 1 of 5 · 4 min read
Setting a cost and latency budget per feature
Goal: Turn a feature's price, usage and margin into a cost ceiling per task and a p95 latency target.
A budget is a number you decide before building: the most one successful task may cost, and the slowest acceptable response for 95 percent of users. Without it, "is this too expensive?" has no answer, and every model upgrade looks reasonable on its own.
Check yourself · 1 of 3
A feature earns a 6 dollar revenue share per user per month, must keep a 75 percent margin, and each user runs 300 tasks a month. What is the cost ceiling per task?
Why it matters
LLM cost is variable. Each request spends tokens, and a feature that costs a cent in testing can cost thousands a month at real volume. Latency is variable too: users forgive a two-second reply to a chat message and will not forgive it on a button click. A budget turns both into pass or fail.
How to set one
Work backwards from money and from the user.
- Find the revenue per user per month that this feature can claim. If it is part of a 20 dollar plan and is one of four main features, start with a share of that, not the whole plan.
- Subtract the margin you need. If the business wants to keep 70 percent after model costs, the feature may spend 30 percent of the share.
- Estimate tasks per user per month, from similar features or a pilot. Count tasks, not API calls: one task may be several calls.
- Divide. Allowed model spend per user divided by tasks per user is the cost ceiling per task.
- Pick the latency target from the interaction. A streaming chat is judged on time to first token (about a second feels responsive). An autocomplete must be faster. A report generated in the background can take minutes. Write the target as a percentile: "p95 under 3 seconds".
- Write both numbers down next to the feature, with the date and the assumptions.
Before and after
Weak: "Summaries should be cheap and fast."
Better: "Meeting summary. Plan price share: 4 dollars per user per month. Target 70 percent margin, so 1.20 dollars of model spend. Expected 40 summaries per user per month, so the ceiling is 3 cents per successful summary. Streamed; time to first token p95 under 1.5 seconds, full summary p95 under 20 seconds."
Now a design review can ask a real question: does the 12 000-token transcript on the large model fit in 3 cents?
What goes wrong
- Budgeting the average user. A few heavy users can use most of the spend. Set a per-user cap too (see the alerts topic).
- Forgetting that tasks are not calls. An agent that makes six calls per task has six times the cost of one call.
- Setting the latency goal from the best run. Measure the tail, not a demo.
- Never revisiting it. Prices and usage change; review the budget when either does.
Examples
Support reply drafter
Context: A help desk tool charges 30 dollars per agent per month. The drafter gets 20 percent of that as a revenue share: 6 dollars. The business keeps 75 percent, so model spend is 1.50 dollars per agent per month.
Usage: An agent drafts about 300 replies a month, so the ceiling is 0.5 cents per successful draft.
Latency: The draft appears in a side panel while the agent reads the ticket, so a first token under 2 seconds and a full draft under 10 seconds at p95 is enough.
Both numbers go in the feature's README and become the thresholds in dashboards.
Nightly invoice classifier
A finance team classifies 50 000 invoices overnight. Nobody waits for any single one, so the latency budget is a window: all done by 06:00, not a per-item p95.
That changes the cost levers. Because no user is waiting, requests can be queued and sent in batches to a cheaper asynchronous endpoint, and the cost ceiling is set per invoice from the monthly finance budget, not from a per-user price.
Key points
- A budget has two numbers per feature: a cost ceiling per successful task and a latency target stated as a percentile such as p95.
- Derive the cost ceiling by working backwards from revenue share, required margin and expected tasks per user, not from what the model happens to cost.
- Choose the latency metric from the interaction: time to first token for streamed chat, total time for a background job.
- Count tasks, not API calls, because one task may involve several model calls.
- Write the assumptions next to the numbers so the budget can be rechecked when prices or usage change.
Common mistakes
- Writing a goal such as "as cheap as possible" instead of a number that a test or a dashboard can fail.
- Using the average usage per user and ignoring heavy users, who can break the margin alone.
- Setting one latency target for every feature when a streamed chat, an autocomplete and a batch job need different ones.
- Dividing cost by API calls instead of tasks, which hides retries and multi-step runs.
Check yourself · 2 of 3
Which latency target fits a nightly job that classifies 50 000 invoices while nobody is watching?
Check yourself · 3 of 3
A team budgets a feature at 2 cents per call. In production each task makes five calls on average. What is wrong?
Practice items, not counted towards your mastery.
Start here
- Reducing latency (Claude docs) (opens in a new tab)DocsFree
Names the levers: model choice, output length, prompt length and streaming, with guidance on each.
- Latency optimization (OpenAI API docs) (opens in a new tab)DocsFree
Seven principles for cutting latency, including fewer output tokens, fewer requests and parallel calls.
- LLM inference benchmarking metrics (NVIDIA NIM docs) (opens in a new tab)DocsFree
Defines time to first token, inter-token latency, end-to-end latency and throughput precisely.
More for this topic
- Applied LLMs: What we learned from a year of building with LLMs (opens in a new tab)ArticleFree
Practitioner notes on cost, latency and quality trade-offs when running LLM features in production.