LLM API Cost Analysis and Inference Performance Benchmarking Guide
This guide explains why a low per-token price does not guarantee a low bill, and how to evaluate LLM API services with a unified baseline. It covers profiling your own traffic, normalizing cost to a per-billion-token basis, breaking latency into measurable metrics such as TTFT and token/s, isolating slowdowns from client to server, and practical recommendations for cost, stability, observability, and capacity. Use it to make evidence-based tradeoffs among cost, speed, and reliability.
1. Why a Low Unit Price Does Not Mean a Low Bill
When integrating LLM capabilities into production systems, the most common mistake is looking only at the official price list. The real bill is determined by four variables together: the ratio of input to output tokens, cache hit rate, the distribution of off-peak versus peak usage, and the extra consumption caused by failed-request retries. A model with a very low listed price can end up costing several times more than expected if it has a high output share, a low cache hit rate, and traffic concentrated at peak hours. Conversely, a mid-priced model can be pushed very low in actual spend if most requests hit the cache and outputs are extremely short.
So the correct starting point for cost evaluation is not the price sheet but a profile of your own real traffic. It is recommended to sample one to two weeks of call logs and compute four baseline metrics: average input length, average output length, cache hit rate, and request time-of-day distribution. With these four numbers, any model’s price can be converted into the same comparable basis.
2. Building a Unified Cost Baseline: The Per-Billion-Token Method
Cross-model comparison must eliminate unit differences. A common industry practice is to normalize cost to a fixed scale, for example one billion tokens. The steps are:
- Export total tokens and total cost from the bill or usage dashboard, and compute the measured average price (CNY per million tokens).
- Group token volume into three categories—input, output, and cache hits—to obtain the structural share.
- Scale to a unified baseline:
baseline cost = measured average price × 1000(one billion tokens equals one thousand million tokens). - Compute separately for peak and off-peak periods to get a cost range rather than a single point value.
Illustrative calculation logic (pseudocode):
total_tokens = 180_000_000total_cost = 31.0 # CNYavg_price = total_cost / (total_tokens / 1_000_000) # CNY per million tokensbaseline_1B = avg_price * 1000 # cost per billion tokens# When output share is very low and cache hits are high, the average price drops significantlyeffective_price = input_price * (1 - cache_hit) \+ cached_price * cache_hit \+ output_price * output_ratio
A typical observation is this: in scenarios where output share is under one percent and many requests hit the cache, the measured average price can fall to the order of a few tenths of a CNY per million tokens, which converts to just over a hundred CNY per billion tokens—roughly on par with comparable off-peak services. Once peak hours begin, however, the same-basis cost can double. This shows that “cache hit rate” and “output share” are the two knobs with the largest weight in the cost model, and optimizing prompt prefix reuse and compressing output length is often more effective than switching models.
3. Throughput and Latency: Breaking “Slow” into Locatable Metrics
A subjective feeling of “lag” must be decomposed into measurable items, otherwise it cannot be attributed. At least four categories of metrics should be collected:
- Time to first token (TTFT): reflects queuing and cold starts;
- Reasoning-chain generation rate (token/s): reflects whether the inference stage is throttled or resource-constrained;
- Final output rate (token/s): reflects the smoothness users actually perceive;
- End-to-end completion time and error rate: reflect overall availability.
A common pattern in practice is that during off-peak periods the rate stays stable in a mid-to-high range with acceptable fluctuation; during peak periods the reasoning-chain rate drops to single digits and the output rate falls in tandem to roughly teens or twenties of token/s. At this point, if the client does not display the reasoning chain, users will mistakenly assume the connection dropped or deadlocked. Observability is therefore part of the experience itself: continuously rendering reasoning-chain deltas, real-time rate, and tokens used into the interface can significantly reduce the misjudgment rate of “is it broken?”
4. Attribution Method: Rule Out the Client First, Then Suspect the Server
Slowdown troubleshooting should follow a near-to-far order to avoid switching models by mistake:
- Client and network layer: launch multiple small requests concurrently on the same machine and compare performance across different service nodes; if other services run at normal rates, local network issues can be ruled out.
- Concurrency and quota layer: check the concurrency limits and per-minute token quota given in the documentation; a single serial request task usually will not trigger rate limiting, so if slowdown still occurs, server-side resource shortage is more likely.
- Server load layer: observe whether the slowdown is strongly correlated with fixed time periods; if it recurs at the same time every day, backend queuing can basically be determined.
- Request characteristic layer: very long context, complex tool calls, and long reasoning chains naturally lower the rate, and need to be statistically separated from time-of-day factors.
Illustrative load-test script (pseudocode, with interface details expressed as a generic call):
for model in [candidate_models]:for concurrency in [1, 4, 8]:start = now()stream = call_model(model, prompt, concurrency)for chunk in stream:record(ttft, reasoning_tps, output_tps)report(p50, p95, error_rate)
The key is to treat concurrency as the independent variable: if the rate drops linearly as concurrency rises, it is a quota or queuing problem; if it is equally slow at a single concurrency, it is a problem with the model itself or with server load.
5. Engineering Recommendations
- Cost side: prioritize improving prefix cache reuse by keeping stable system prompts and few-shot examples at the front and unchanged; set a hard cap on output length; schedule batchable offline tasks to off-peak periods.
- Stability side: set timeouts and a retry budget to avoid long reasoning-chain requests occupying connections indefinitely; implement multi-model fallback routing that automatically switches to a backup model when the primary model’s rate falls below a threshold.
- Observability side: integrate logging services and monitoring alerts, build dashboards for TTFT, reasoning-chain rate, output rate, error rate, and cache hit rate, and configure time-of-day thresholds.
- Capacity side: apply client-side rate limiting and queue-based peak shaving against the concurrency limit, smoothing burst traffic to within the quota.
6. Conclusion
To assess whether a model service is worth investing in, look at three curves at the same time: the curve of cost as traffic structure changes, the curve of throughput as time of day changes, and the curve of error rate as concurrency changes. Only by quantifying all three on a unified baseline and exposing them to users through visualization can you make evidence-based tradeoffs among “cheap,” “fast,” and “stable,” instead of drawing conclusions from a single episode of lag during peak hours.
