How to Calculate LLM API Cost-Effectiveness After a Price Increase
When a cloud provider raises LLM API prices, the real driver of your bill is call structure rather than the per-token rate. This article breaks down how input, output, and cached input tokens are priced separately, provides a reusable Python cost model, maps three model tiers to different workloads, and outlines routing and observability practices to keep cost-effectiveness under control.
1. After a Price Hike, the Lowest Unit Price Is No Longer the Best Value
The industry has recently seen a round of API price adjustments: one cloud provider announced a major repricing of its large model services, with some tiers rising by more than three times, alongside the release of a more capable official version. Discussions in developer communities tend to focus on “how much it went up,” but what actually affects your bill is the call structure, not the unit price itself.
For the same model, input tokens, output tokens, and cached input tokens are often billed at three separate rates. Across different models, the input-to-output rate ratio and the size of the cache discount also vary. So the question “how much does 1 million tokens cost” is nearly impossible to answer without qualification.
This article makes no recommendations about any specific product. Instead, it abstracts the problem into a general engineering question: given the characteristics of a business workload, how do you build a reproducible cost model and use it to select a model?
2. The Three Token Categories Must Be Priced Separately
The billing dimensions of mainstream LLM APIs generally fall into three categories:
- Input tokens: prompts, system instructions, retrieved context, conversation history, and so on.
- Output tokens: content generated by the model, usually priced significantly higher than input, commonly several times the input rate.
- Cached input tokens: when a repeated common prefix (such as a fixed system prompt, a long document, or codebase context) hits the cache, it is billed at a rate far below normal input.
Two engineering conclusions here are easy to overlook:
- The output rate multiplier determines workload fit. If a tier charges 6 times the input rate for output, then generation-heavy tasks (long-form writing, code generation, structured extraction) will be dominated by output-side cost, while understanding-heavy tasks (long-document classification, retrieval reranking, intent recognition) will be dominated by input-side cost.
- The cache hit rate is a controllable variable. Placing stable, unchanging content first and variable content last is the most general way to improve the cache hit rate. Cache discounts are typically on the order of one-tenth, so raising the hit rate from 0 to 60% can cut input cost by more than half.
3. A Reusable Cost Estimation Model
Let the input rate be p_in, the output rate p_out, and the cached input rate p_cache, all per million tokens; let the average input and output per request be L_in and L_out, the cache hit rate h, and the daily call volume N.
def daily_cost(p_in, p_out, p_cache, L_in, L_out, h, N):"""Rates are per million tokens; lengths are in tokens; h is the cache hit rate (0~1)"""cached = L_in * hfresh = L_in - cachedper_req = (fresh * p_in + cached * p_cache + L_out * p_out) / 1_000_000return per_req * N# Example: Tier A (capability-first) vs. Tier B (cost-first); values only illustrate the structurecost_A = daily_cost(5.0, 30.0, 0.5, 4000, 800, 0.5, 20000)cost_B = daily_cost(0.2, 1.2, 0.02, 4000, 800, 0.5, 20000)print(round(cost_A, 2), round(cost_B, 2))
The value of this model is that it turns “a price increase,” an external event, into three internal parameters you can optimize: shorten input length, control output length, and raise the cache hit rate.
4. Three Tiers and How to Match Them to Scenarios
Looking at publicly available industry pricing structures, the same series usually offers three tiers, which can be abstracted as:
| Tier | Typical characteristics | Suitable scenarios |
|---|---|---|
| Capability-first | Highest input and output rates, best performance on complex reasoning | Complex professional tasks, long-chain agents, difficult code fixes |
| Balanced | Mid-range rates, a compromise between capability and cost | General business assistants, customer service, routine development support |
| Cost-sensitive | Lowest rates, and the lowest output multiplier as well | High-concurrency classification, batch labeling, log summarization |
The key judgment: do not cover all traffic with a single tier. A more robust approach is tiered routing—handle requests with the low-cost tier first, then escalate requests with insufficient confidence or complexity above a threshold to the high-capability tier.
request -> complexity assessment (length/rules/small-model scoring)├─ simple -> cost-sensitive tier└─ complex -> capability-first tier
5. Four Common Pitfalls in Enterprise Adoption
- Budgeting on input rate alone. The output side is often the main line item, and long-output scenarios can differ by several times.
- Ignoring cache semantics. Caching usually requires an exact prefix match; putting dynamic timestamps or random IDs at the start of a prompt will drive the hit rate to zero.
- Lacking observability. Log the input, output, and cached token counts, latency, and failure rate for every call, and build a cost dashboard with monitoring and alerts; otherwise, you cannot trace where cost comes from after a repricing.
- Migrating everything at once. In the early stage of a new version, retain canary release and rollback capability, compare quality and unit cost on an offline evaluation set, and then ramp up gradually.
6. Conclusion
Price adjustments are the norm; the capability that stays stable is breaking cost down into computable, optimizable engineering metrics. The recommended order is: clarify the input-to-output ratio of the task → estimate the daily cost of each tier with a unified formula → design a cache-friendly prompt structure → set up tiered routing and a cost dashboard → validate with a canary release before ramping up. This way, no matter how the market reprices, you keep control of cost-effectiveness. If you need elastic compute and a complete observability system, you can build your own on general cloud capabilities such as those offered by Baidu AI Cloud (for example, container platforms, object storage, logging services, and monitoring and alerting), avoiding lock-in to a single price.
