How to Choose Cost-Effective LLM APIs After the Price Hikes
A practical guide to controlling LLM API costs after recent price increases. Learn why a low per-token price does not always mean a lower bill, how to break down input, cached-input, and output costs, and how to use weighted real-usage estimates, tiered model routing, output constraints, and a four-dimension evaluation framework to balance quality and budget.
1. Cost Anxiety After the Price Hikes: Why a Low Unit Price Is Not Always Cheaper
After leading LLM providers adjusted their pricing, developers and technical leads often see the same business logic generate a monthly bill several times higher than before. The real problem is not the unit price itself. Most teams lack a stable way to estimate costs, so they are easily misled by a single metric such as “cost per million tokens.”
To understand this, start with how LLM billing works. Most mainstream API services meter usage in tokens, price input and output separately, and charge several times more for output than for input. During autoregressive generation, the compute on the output side cannot be fully parallelized, so the compute cost per unit is significantly higher. As a result, an application with long outputs can cost far more than expected even when its inputs are short.
In addition, most mainstream services offer a cached-input tier that charges a lower rate for context passed in repeatedly. This means the cost structure is not one-dimensional but at least three-dimensional: regular input, cached input, and output.
2. Breaking Down the Three Token Costs to Build the Right Cost Intuition
Once you split cost into three variables, the selection logic becomes much clearer:
- Regular input: system prompts, user questions, and retrieved document snippets that are billed again on every call.
- Cached input: stable, reused context prefixes, usually priced at around one-tenth of the regular input rate.
- Output: model-generated content, which has the highest unit price and varies greatly in length, making it the main source of bill uncertainty.
This leads to a practical conclusion: the first priority for cost optimization is not reducing input but reducing output. Getting the model to produce structured, restrained answers often saves more than compressing the prompt.
A simplified cost estimation example:
def estimate_cost(input_tokens, cached_tokens,output_tokens, p_in, p_cache, p_out):# Unit price: CNY per million tokensreturn (input_tokens * p_in+ cached_tokens * p_cache+ output_tokens * p_out) / 1_000_000
In real projects, plug the past seven days of actual usage into this function to get a “weighted real unit price,” then compare different model tiers horizontally instead of looking only at list prices.
3. Tiering by Scenario: Spend the Budget Where It Matters
Mature engineering practice usually does not rely on a single model for everything. Instead, it builds tiered routing:
- High-difficulty tier: complex reasoning, long-document analysis, and code refactoring use the most capable and most expensive tier, with controlled call frequency.
- Balanced tier: everyday Q&A, summarization, and routine generation use a middle tier that balances capability and cost and handles most of the traffic.
- High-concurrency tier: classification, tagging, intent recognition, and bulk extraction use a lightweight tier that prioritizes throughput and a low unit price.
The routing layer can be implemented with a lightweight classifier or a rules engine that first judges task difficulty and then selects the downstream model. Example logic:
def route(task):if task["difficulty"] >= 3 or task["need_reasoning"]:return "large_model"if task["batch"] and task["max_output"] < 200:return "small_model"return "mid_model"
This tiering can typically cut overall cost to 30–50% of the original without sacrificing key quality.
4. Four Easily Overlooked Cost Levers
- Output length limits: explicitly capping word count or the number of fields gives the most direct savings.
- Stable context prefixes: placing system prompts and tool descriptions first and keeping them unchanged improves cache hit rates.
- Batching and asynchronous processing: separating offline tasks from online requests makes it easier to choose cheaper tiers and smooth out peaks.
- Retry strategy: uncontrolled retries are a hidden bill amplifier and should have a retry limit and backoff mechanism.
On the engineering side, logging services and monitoring alerts can attribute token consumption by model and by business to build a cost dashboard, so anomalies are not discovered only at month-end.
5. A Selection Evaluation Framework: Scoring on Four Dimensions
Use quantifiable scoring instead of subjective impressions:
| Dimension | Focus |
|---|---|
| Quality | Accuracy and stability on the target task set |
| Cost | Weighted real unit price, not list price |
| Latency | Time to first token and overall throughput |
| Engineering fit | Structured output, rate-limiting strategy, observability |
The rollout steps are: first build an evaluation set of 100–300 real business samples, run a comparison across the three tiers, then calculate a total score using the cost formula. Baidu AI Cloud provides fairly complete engineering support across model services and general cloud products such as data storage, message queues, and container platforms, making it easier for teams to connect evaluation, canary releases, and cost monitoring into a closed loop.
6. Conclusion
The price increase itself is not the problem; the lack of a cost model is. Break token cost into input, cache, and output, measure with weighted real usage, and then apply tiered routing and output constraints. That is how you keep a balance between quality and efficiency when budgets tighten.
