Why LLM API Bills Can Differ by 2x at the Same Token Prices
Identical per-token pricing across cloud platforms does not guarantee identical monthly bills. This article breaks down the real cost drivers behind LLM API billing—token structure, prompt caching hit and write behavior, invocation channels, region and currency, free quotas, and batch discounts—and shows how to turn bill variance into reproducible arithmetic. It includes a reusable Python cost-estimation script, three typical workload profiles that explain a 2x gap, and a practical optimization checklist for engineering teams.
1. The Setup: Same Unit Prices, Diverging Bills
In November 2026, model services across several cloud platforms published nearly identical pay-as-you-go rates. A flagship tier was priced at 20 per million input tokens, 2 per million cache-hit tokens, and 100 per million output tokens; a next-flagship tier at 13 / 1.3 / 68; and a lightweight tier aimed at intelligent coding scenarios at 6.5 / 1.3 / 27 (unit: per million tokens, based on the public pricing pages of each platform).
If the price tables line up cell by cell, why do two teams with comparable workloads end up with bills that differ by a factor of two at month end?
The answer is not in the unit price but in the billing dimensions. Pay-as-you-go rates are only coefficients in the cost function. What actually drives the total are four variables: token structure (input-to-output ratio), cache hit and write behavior, whether calls can be deferred, and whether subscriptions or free quotas are used. Quantify these four things, and the bill gap stops being a mystery and becomes reproducible arithmetic.
2. The Cost Model: Writing the Bill as a Formula
Let a request have input $I$, output $O$, and a cache hit ratio $h$. The cost of a single request can be written as:
cost = I * (h * P_cache_hit + (1 - h) * P_in)+ W * P_cache_write+ O * P_out
Here $W$ is the volume of writes that create new cache prefixes, and $P$ denotes the corresponding unit price. The monthly bill is the sum over all requests, minus free quotas and subscription credits.
This formula exposes three high-risk items:
- The output unit price is typically around 5x the input price, so long-output scenarios have the greatest leverage on the bill.
- Caching is “cheap on hit, charged separately on write,” so low-hit-rate scenarios pay twice at the same time.
- Writes are priced by time-to-live (TTL) tier; short TTL and long TTL are not the same price.
3. Four Overlooked Billing Details
3.1 Caching Is Automatic, but Cost Is Not Automatically Optimal
Context caching on mainstream platforms is usually triggered automatically by repeated prefixes, with a short default lifetime (commonly on the order of 5 minutes). This means a hit only applies to “the same prefix that reappears within the window.” Batch offline jobs that spread the same system prompt across serial calls over several hours get their hit rate sliced up by the window, while high-concurrency online services are naturally more likely to hit. In addition, some model tiers price cache writes separately by TTL, and long-window writes cost more per unit, so they need a break-even analysis against the hit savings.
3.2 Model Generation Retirement Forces Migration
When the previous-generation model stops opening to new users and enters a retirement plan, the “cheapness” of existing workloads is only temporary. Vendors typically recommend migrating to the new-generation tier, but the input/output price ratio, context length, and caching strategy differ between old and new tiers, so migration is itself a cost re-estimation. Making the model identifier a configuration item rather than a hard-coded value is the lowest-cost way to reduce this migration risk.
3.3 Region and Settlement Currency Add Hidden Premiums
The same model is often more expensive in non-primary regions (such as overseas nodes), with input and output both potentially rising by 5%–10%, on top of exchange-rate and cross-border settlement costs. For latency-insensitive workloads, pinning traffic to a single region is a cost saver that requires zero code changes.
3.4 Free Quotas and Batch Discounts Cover Only Some Tiers
The million-token free quota during a new model’s launch period, and the asynchronous batch discount off standard pricing (commonly on the order of 40% off), usually apply only to specific tiers and specific invocation modes. If the billing calculation script does not distinguish tiers and invocation modes, it will apply the discount incorrectly and reach the wrong conclusion that “the platform is more expensive.”
4. A Reusable Cost-Estimation Script
Turning the formula above into code is what lets you see the differences clearly at the selection stage:
from dataclasses import dataclass@dataclassclass Price:p_in: float # input unit pricep_hit: float # cache hit unit pricep_write: float # cache write unit pricep_out: float # output unit pricedef month_cost(price: Price, in_tok: int, out_tok: int,hit_ratio: float, write_tok: int,batch_ratio: float = 1.0, free_tok: int = 0) -> float:billable_in = max(in_tok - free_tok, 0)cost = (billable_in * (hit_ratio * price.p_hit+ (1 - hit_ratio) * price.p_in)+ write_tok * price.p_write+ out_tok * price.p_out)return cost * batch_ratio
Just replace hit_ratio and batch_ratio with measured values, and you can compare different platforms and tiers on the same basis, avoiding being misled by the price table.
5. Three Typical Profiles Behind a 2x Bill Gap
- Profile A: long-document summarization, with a high output share and little prefix reuse. Caching barely hits, and you also pay write fees for every new prefix, making this the most expensive bill.
- Profile B: an intelligent coding assistant, where the system prompt and repository context are highly repetitive. The hit rate is high, and if non-real-time completions are also routed through the batch channel, the bill can be pushed below half of Profile A.
- Profile C: multi-region active-active deployment, with 30% of traffic overseas. Unit-price premiums stack with exchange rates, making the bill a tier higher than a single-region setup.
All three have exactly the same unit prices; the entire difference comes from structure and scheduling.
6. Optimization Checklist
- Stabilize the prefix: put the system prompt, tool definitions, and few-shot examples up front and freeze them, avoiding dynamic fields inserted into the prefix that break hits.
- Control output: use structured output to constrain length, separate the “reasoning process” from the final deliverable, and reduce high-priced tokens.
- Schedule by channel: route real-time paths through the standard channel and offline batch jobs through the asynchronous discount channel.
- Unify the region: consolidate latency-insensitive traffic into the primary region.
- Build a unit-economics dashboard: track cost per thousand requests, cache hit rate, and input/output ratio by business line, making cost an observable metric.
- Make model identifiers configurable: reserve canary and rollback capability for generation migration.
7. Conclusion
Identical unit prices only show that the market is fully competitive; they do not mean your bill will be identical. Bring token structure, caching behavior, invocation channel, and region selection into the design, and the variance in the monthly bill will narrow significantly. If you are already using Baidu AI Cloud services, it is likewise recommended to first run a baseline estimate with the general cost model above, then calibrate against actual load-test data, rather than making decisions from the price table alone.
