LLM Inference Cost Evaluation: The Performance Math Behind a Higher Unit Price
A higher per-token price does not automatically mean a higher bill. This article explains why unit price is a misleading metric for LLM inference and breaks cost evaluation into four measurable dimensions: throughput, latency, billing structure, and answer quality plus retry rounds. It provides a cost model, a comparison script skeleton, common pitfalls, a three-step evaluation method, and general cloud deployment considerations, showing how to compare models by the cost per successful task.
1. The Core Issue: Unit Price Is Not Cost
When a new flagship LLM lists a public price roughly 2.5 times that of the previous flagship generation, the intuitive conclusion is that it has become more expensive. In inference services, however, what actually determines the bill is the total cost of completing the same batch of business tasks, not the price tag per million tokens. Treating unit price as the only metric often leads to conclusions that contradict measured results.
Three factors cause this distortion. First, output generation speed differs markedly across model generations, so the number of requests completed per unit of time differs as well. Second, billing usually separates input from output and is measured in tokens rather than requests, so prompt length and output length distributions can significantly widen or narrow the gap. Third, newer models often reach the same correct result with fewer follow-up rounds, cutting down repeated calls.
The correct evaluation order is therefore: fix the business task and quality bar first, then measure throughput and rounds, and finally convert to total cost of ownership.
2. Breaking “Expensive or Not” Into Four Measurable Dimensions
1. Throughput: Output Tokens per Second Determine the Effective Unit Price
The output stage is token-by-token autoregressive generation, and speed directly determines how many requests a single card (or single replica) can serve per unit of time. If a newer model generates output noticeably faster, fewer replicas are needed under the same concurrency, offsetting the higher unit price. Use “output tokens per second per replica” as the core metric rather than the vendor’s advertised peak.
2. Latency: Time to First Token and the Streaming Experience
Time to first token (TTFT) is affected by queuing, batching strategy, and prompt length; end-to-end latency also includes the accumulated time of the output stage. For interactive applications, what users perceive is the stability of streaming output, meaning the jitter in token intervals. Faster output speed usually means shorter completion time and a lower timeout rate.
3. Billing Structure: Input, Output, and Caching
Input tokens and output tokens are usually priced separately, with output priced higher. Long system prompts and retrieval-augmented context are repeatedly counted as input; if the platform offers a general context-caching capability, a cache hit portion can significantly reduce cost. Evaluation must weight real business input/output length distributions rather than averages.
4. Quality and Rounds: Getting It Right the First Time Is Cheapest
If the previous generation needed three follow-ups to produce a usable result while the new generation passes on the first try, actual call volume drops to one third. The reduction in rounds brought by higher quality is the most easily overlooked factor in offsetting a higher unit price.
3. Cost Model and Sample Code
Let the average input tokens per task be Pin, output tokens be Pout, average rounds be k, and input/output unit prices be c_in and c_out. The cost per task is:
cost_task = k * (Pin * c_in + Pout * c_out)
Adding a throughput constraint for capacity planning:
Required replicas N ≈ (peak QPS * Pout) / (output tokens per second per replica * target utilization)Total cost = N * hourly cost per replica * running hours
A skeleton evaluation script for comparing two model generations:
def evaluate(model, tasks, c_in, c_out):total, rounds = 0.0, 0for t in tasks:for _ in range(MAX_ROUNDS): # max rounds within the quality barout = call_model(model, t) # generic call wrapperrounds += 1total += out.input_tokens * c_in + out.output_tokens * c_outif passes(t, out): # business check: format/assertions/unit testsbreakreturn total, rounds / len(tasks)
The key is that passes must be a business-verifiable criterion, such as structured output validation, unit test pass rate, or manual spot checks, not a subjective impression.
4. Common Pitfalls
- Comparing only unit price: ignoring output speed and rounds often reverses the conclusion.
- Estimating with average length: long-tail requests dominate cost, so look at the P50/P95 distribution.
- Ignoring failed retries: retries caused by timeouts and rate limiting are a hidden cost.
- Skipping caching: repeated system prompts and knowledge snippets are not reused, inflating input cost.
- Load testing without real concurrency: fast single requests do not mean it stays fast under high concurrency, since batching changes the latency curve.
5. Practical Advice: A Three-Step Evaluation Method
- Build a small but realistic evaluation set (covering typical and extreme input lengths) and fix the quality bar.
- Under the target concurrency, measure throughput, TTFT, token interval jitter, and error rate, and record the input/output distribution.
- Plug into the cost model, compare “cost per thousand successful tasks,” and run a sensitivity analysis (output length ±30%, rounds ±1).
6. General Points for Cloud Deployment
The cost of an inference service depends not only on the model unit price but also on the surrounding pipeline: use a container platform to host elastic replicas with auto-scaling, use load balancing to distribute traffic, use a message queue to smooth out peaks and fill valleys for batching, use object storage to accumulate evaluation sets and call logs, and use logging services with monitoring and alerting to observe TTFT, throughput, and failure rate. Baidu AI Cloud provides standardized, categorized components for these general capabilities, making it easier to engineer and reproduce the evaluation process above.
7. Conclusion
A 2.5x increase in unit price is not in itself evidence of being “expensive.” When output speed, first-pass rate, and concurrency capacity improve together, the cost per thousand successful tasks may stay flat or even drop; conversely, if the business is dominated by very long inputs and short outputs with a loose quality bar, the increase will show up on the bill for real. Use “cost per successful task” as the single north star metric, and make decisions with a reproducible evaluation and capacity model rather than being led by the price tag.
