LLM API Cost Comparison and Model Selection: A Practical Guide
This article explains why a low per-token price does not always lead to a low bill, and shows how to build a blended cost model from cache-hit reads, uncached input, and output tokens. It covers price tiers, time-of-day and long-context cost variations, and a practical optimization checklist for routing, caching, and observability.
1. Why a Cheap Unit Price Does Not Mean a Cheap Bill
When teams start integrating LLM capabilities, the first thing they usually look at is the price per thousand tokens. Yet at the end of the month, the actual bill is often several times higher than expected. The reason is straightforward: the cost of a request is not determined by a single price, but by three billing components stacked together — the cached read portion, the uncached input portion, and the output generated by the model. The unit prices of these three differ significantly, and the composition ratio varies completely from one request to another.
So the first step in cost accounting is not comparing prices, but building a conversion method that calculates “based on your actual ratio”: weight the three prices by your real traffic structure to get a comparable blended unit price, then rank and select models accordingly.
2. A Unified Conversion Model: Combining Three Prices into One Comparable Number
Let the cache-hit read unit price be p_cache, the uncached input unit price be p_in, and the output unit price be p_out. In a single request (or a batch of requests), let the cache-hit token share be a, the uncached input share be b, and the output share be c, with a+b+c=1. The blended unit price is:
cost_per_request = a * p_cache + b * p_in + c * p_out
Example code:
def blended_price(p_cache, p_in, p_out, a, b, c):assert abs(a + b + c - 1.0) < 1e-6return a * p_cache + b * p_in + c * p_out# Long system prompt + short Q&A: high cache hit, short outputprint(blended_price(0.03, 0.30, 1.20, a=0.80, b=0.15, c=0.05))
The key point is that a, b, and c must come from your own instrumentation, not from guesswork. It is best to measure them per business scenario, since the composition ratios differ dramatically across cases such as code completion, document summarization, and customer support Q&A.
3. Cost Tiers: Layered Awareness from Very Low to Very High
After unified conversion, the models on the market can be roughly divided into several price tiers. The following is a layered illustration ordered by blended unit price from low to high (the numbers only show the order of magnitude; the actual prices published by your chosen service at the time prevail):
- Tier 1 (about 0.3–1.0): lightweight and small-size models, suitable for classification, extraction, format conversion, and simple completion.
- Tier 2 (about 1.0–2.0): mid-range general models, the cost-effective zone for everyday conversation and routine code generation.
- Tier 3 (about 3.5–7.0): more capable general and multimodal models, suitable for complex reasoning and long context.
- Tier 4 (about 7.0–14.0): high-capability tier, for long-chain tasks and complex tool calls.
- Tier 5 (about 14.0–28.0): flagship tier, for high-difficulty reasoning and critical decisions.
- Tier 6 (about 47.0 and above): top tier, used only when the benefit clearly outweighs the cost.
The point of tiering is not “more expensive is better,” but to give routing strategies a basis: the vast majority of requests should fall in Tier 1 and Tier 2, and only the small amount of traffic judged as “difficult requests” should move up to higher tiers.
4. Cost Fluctuations from Time-of-Day Differences and Long Context
Beyond the three prices, there are two common sources of fluctuation. The first is time-of-day differences: the unit price of the same model may differ by more than 30% between peak and off-peak periods, so batch tasks that are not sensitive to latency should be actively shifted off-peak. The second is context-length tiers: some models set higher price tiers for extra-long context, which means “stuffing all history into the prompt” is an expensive habit.
Engineering countermeasures include: summarizing and compressing conversation history, keeping only the necessary retrieval fragments, and designing the stable, unchanging prefix as cacheable content to raise the value of a.
5. An Actionable Cost Optimization Checklist
- Prefix normalization: put the system prompt, tool definitions, and few-shot examples at the very front and keep them byte-level stable to maximize cache hits.
- Tiered routing: first use a small model to judge difficulty, then decide whether to upgrade, avoiding “everything goes to the flagship.”
- Output constraints: use structured output and length limits to control
c; output is usually the most expensive segment. - Off-peak scheduling: put batch tasks in low-peak queues, combined with message queues and task retries.
- Observability: log the three token counts and the cost of each request in your logging service and monitoring alerts, forming a cost dashboard and budget threshold alerts.
- Regular regression: retest models across tiers with a fixed evaluation set, avoiding selection based on impression alone.
6. Selection Recommendations
Treat “effectiveness — cost — latency” as a three-dimensional decision: first use an evaluation set to determine the minimum acceptable effectiveness line, then choose the model with the lowest blended unit price among those that meet that line, and finally use routing and caching to bring the overall bill within budget. If you use Baidu AI Cloud capabilities, it is likewise recommended to use the conversion model above to unify the calculation basis and avoid prices from different sources being incomparable.
