LLM API Pricing and Model Selection: A Practical Guide for Large-Scale Deployments
This guide breaks down how modern LLM API pricing works and why a low per-token rate does not guarantee a low bill. It covers the main billing dimensions (input tokens, output tokens, cached input, and add-ons), explains how prefix caching can cut input costs dramatically, and shows how time-based pricing turns scheduling into a cost optimization lever. It also outlines a four-step selection methodology based on your own traffic and a total cost of ownership checklist for comparing models on unit business cost.
1. Background: Cost Structure Changes at Trillion-Parameter Scale
Once large language models reach the trillion-parameter range, the engineering focus shifts from “can we run it” to “how much does each call actually cost.” A typical pattern is worth noting: one model offered a limited-time price of 2 CNY per million input tokens, 8 CNY per million output tokens, and 0.04 CNY per million cached input tokens. That price was clearly lower than several overseas models in a side-by-side comparison, yet the advantage over domestic models was not pronounced. One lightweight model led in 14 of 26 comparable tests, with peak-hour pricing on par and off-peak pricing cut in half.
The real takeaway for developers is not any single vendor’s quote, but three general rules:
- Billing is multi-dimensional; a low unit price does not mean a low bill.
- Benchmark leaderboards often diverge from real business traffic, so selection must return to your own datasets.
- Time-based pricing and cache billing are turning “call strategy” into a standalone engineering capability.
2. Billing Dimensions: What Actually Determines Your Bill
Mainstream LLM API billing typically includes four dimensions. Understanding them matters more than memorizing a specific unit price.
- Input tokens: system prompts, conversation history, and retrieval-augmented context. This often dominates in long-context scenarios.
- Output tokens: usually priced at several times the input rate, because the generation stage cannot be parallelized. Controlling output length is the most direct way to save money.
- Cached input: for repeated requests with an identical prefix, the cached portion is billed at a significantly lower rate. It rewards a “stable prefix design.”
- Additional dimensions: batch/async discounts, off-peak discounts, and extra charges for multimodal or long-context requests.
This leads to a key conclusion: real cost ≈ input tokens × input price × (1 − cache hit rate) + input tokens × cache price × cache hit rate + output tokens × output price. Cache hit rate and output length often influence the final bill more than unit price differences do.
Illustrative cost estimation logic (pseudocode, expressing the calculation approach only):
def estimate_cost(reqs, price):total = 0.0for r in reqs:hit = r.prefix_tokens if r.cache_hit else 0miss = r.input_tokens - hittotal += (miss * price.in_price+ hit * price.cache_price+ r.output_tokens * price.out_price) / 1_000_000return total
3. Using Cache Billing Correctly: Turn the Prefix into a Stable Asset
Caching can push input costs down to a fraction of the original because it effectively prepays for reusable computation once. To keep the prefix stable, follow a few constraints:
- Fix the prefix order: put the system prompt, tool definitions, and domain knowledge first, and user input last.
- Keep volatile content such as timestamps, random IDs, and live counters out of the prefix.
- Keep the prefix byte-for-byte identical within a session; do not insert dynamic content in the middle.
- In batch jobs, group requests that share a template to raise the hit rate.
Note that caches usually have a time-to-live and capacity limits, so a hit is not permanently valid. Under high concurrency, treat the hit rate as an observable metric and monitor it continuously rather than assuming it stays at a fixed value.
4. Peak and Off-Peak Hours: Scheduling as Cost Optimization
Time-based pricing means the same request can cost twice as much depending on when it runs. Practical approaches include:
- Task tiering: route online interactions to peak hours and move offline batch work (data cleaning, batch summarization, offline evaluation) to off-peak windows.
- Queue-based peak shaving: buffer burst traffic with a message queue and let consumers adjust concurrency according to price windows.
- Elastic scaling: have the container platform auto-scale based on queue length to avoid paying for peak capacity year-round.
- Observability loop: build a per-request cost dashboard through logging and monitoring/alerting, aggregated by business line.
5. Selection Methodology: Aligning Benchmark Scores with Business Metrics
Leading in more benchmark items does not mean a model is better for your scenario. A four-step approach is recommended:
- Sample real traffic and build an evaluation set that reflects distributions such as long context, multi-turn, and structured output.
- Define business metrics (accuracy, format compliance rate, refusal rate) and latency percentiles (P50/P95).
- Align measurement on the same evaluation set and record input/output length distributions to avoid a false “short input vs. long input” comparison.
- Calculate total cost of ownership rather than comparing unit prices.
6. Total Cost of Ownership Checklist
Beyond token fees, also account for: repeated billing from retries and failed requests, extra input from context bloat, hidden waste from cache misses, cross-zone or cross-region network and storage overhead, queuing and timeout costs caused by rate limiting, and the labor of migration and adaptation. Only when these are folded into a unit business cost (such as “cost per thousand Q&A turns”) do selection conclusions become comparable.
7. Implementation Recommendations
If an organization already uses model services on Baidu AI Cloud, it can combine object storage to accumulate evaluation sets, a message queue for peak shaving, a container platform for elastic inference, and a logging/monitoring system for cost attribution, forming a “measurable — schedulable — optimizable” loop. The core principle: first validate effectiveness with your own data, then use call strategy to reduce costs beyond unit price, and finally use unit business cost as the single decision criterion.
