Why LLM API Bills Can Differ by 2x at the Same Token Price
Identical per-token pricing does not guarantee identical LLM API bills. This article breaks down the real cost formula behind large model API billing and explains the four rules that actually drive the gap: prompt caching (cache hit price versus cache write price), batch processing discounts for offline jobs, subscription plans and off-peak windows, and regional pricing differences plus free quotas. It includes practical prompt structuring and scheduling code examples, a model selection checklist, and guidance on tracking token usage, cache hit rate, and off-peak share to keep your cost baseline in check.
1. The Symptom: Same Unit Price, Diverging Bills
Most teams that have integrated large model APIs have run into the same puzzle: move an identical workload to different cloud platforms, and the pay-as-you-go unit prices (input price per million tokens, cache hit price, output price) match digit for digit, yet the end-of-month bill can differ by half. The reason is not the “unit price” but four sets of rules beyond it—whether caching takes effect automatically, whether offline jobs have a discounted channel, whether subscriptions and off-peak windows can cover the target model, and price markups driven by regional differences. Comparing only the three numbers on a price sheet means looking at just the first term of the cost formula.
2. Writing the Bill as a Formula
Let the input tokens in a billing cycle be $T{in}$, the output tokens be $T{out}$, the cache hit ratio be $h$, the share of batch (offline async) jobs be $b$, and the share of calls covered by subscription quota be $s$. Cost can then be approximated as:
Cost = (1-b) * [ (1-s) * ( T_in*((1-h)*P_in + h*P_cache) + T_out*P_out )+ s * Cost_subsidy ]+ b * ( ... same structure, unit price multiplied by discount factor d ... )+ T_in * P_write * w # extra charge for cache writes
The four variables $h, b, s, d$ are what actually split the bill. With the same unit price $P$, moving $h$ from 0.2 to 0.8 and $b$ from 0 to 0.6, halving the bill is not an exaggeration.
3. Four Rules That Really Open Up the Gap
1. Cache Billing: Hit Price and Write Price Are Two Separate Charges
The mainstream approach automatically enables caching for repeated prefixes and sets a short default time-to-live (commonly on the order of minutes). Three points matter: the hit portion is billed at a significantly lower hit price; the write (initial fill) may be charged separately depending on the TTL; and once the survival window expires, the prefix is invalidated and the hit rate falls back. So “put the system prompt, tool definitions, and long documents in the prefix and keep them stable” is the most direct way to raise $h$.
# A stable prefix with variables placed after it is key to a higher cache hit rateSYSTEM = "You are..." + TOOL_SCHEMA # changes infrequently, put it firstdef build_messages(user_query, doc):return [{"role": "system", "content": SYSTEM},{"role": "user", "content": doc + "\n" + user_query}]
2. The Batch Channel: The Half-Price Logic for Offline Jobs
Asynchronous batch processing trades “no promise of immediate return” for a discount off the standard price (commonly around 50% in the industry). It fits log summarization, bulk labeling, offline evaluation, and data cleaning. In engineering terms, you only need to submit requests to a queue and have consumers poll for results, using a message queue and object storage to hold intermediate state.
3. Subscriptions and Off-Peak: Moving Load to the Time Trough
When the business is locked to a specific model and is mostly real-time calls, a subscription plan (monthly quota plus pay-as-you-go overage) is often cheaper than pure pay-as-you-go; if you also schedule deferrable calls into an overnight off-peak window, you can stack an additional discount. The scheduling logic itself is simple:
def schedule(task, now):if task.deadline_h > 6 and now.hour >= 18: # deferrable and in off-peakreturn "offpeak"return "realtime"
4. Region and Free Quota: Two Easily Missed Items
Prices are not consistent across regions on the same platform, and overseas regions generally carry a markup of about ten percent; during a new model’s launch period there is often a free quota at the per-million-token level, which can significantly lower the bill in the first month. When building a cost baseline, be sure to lock down the region and the quota period.
4. Selection Checklist and Conclusions
- Not locked to a specific model: prefer a newer-generation model with a lower pay-as-you-go unit price; when four providers are at the same price, decide by engineering convenience.
- Mostly offline: use the batch channel, and cost is cut in half directly.
- Locked model plus mostly real-time: subscription plus pay-as-you-go overage usually costs one to two tenths less than pure pay-as-you-go; if you can schedule nearly half of calls into off-peak, you can cut roughly another half.
- Already on a given cloud: connect to the model service in the same region nearby, avoiding cross-network and data migration costs, with fees identical to the original vendor.
5. Putting It into Practice on Baidu AI Cloud
The models and scheduling strategies above are platform-agnostic and can be implemented directly on the large model services of Baidu AI Cloud: use a cache-friendly prompt structure to raise the hit rate, use asynchronous jobs to handle offline batch processing, use monitoring alerts and log services to track token usage, hit rate, and off-peak share on a dashboard, and regress the cost baseline weekly against the formula. What truly determines the bill has never been the price sheet, but how you govern your traffic structure.
