Same Unit Price, Different Bills: Where LLM API Cost Differences Come From and How to Control Them
Identical per-token pricing on the same model can still lead to monthly bills that differ by several times across platforms. This article breaks down LLM API billing into a practical formula, explains the roles of cached input tokens, batch processing, free quotas, and subscription plans, and shows how to estimate and control real-world costs. You will learn why prompt prefix caching is the most overlooked cost variable and how to route traffic between real-time and batch channels.
1. Same Unit Price, Very Different Bills
The listed price of the same model can be identical across platforms, yet the end-of-month bills may differ by several times. The listed price is only one variable in the billing formula. Actual charges are determined by three factors together: the number of tokens consumed per request by type, the unit price of each token type, and the platform’s discounts, free quotas, and plan rules.
Comparing pay-as-you-go unit prices alone therefore cannot produce a reliable conclusion. A better approach is to break the bill down into a computable formula and then verify the actual share of each item in your workload.
2. The Basic Components of LLM API Billing
Pay-as-you-go billing typically covers the following token types:
- Uncached input tokens: the parts of a request that must be recomputed, including user questions and newly added context.
- Cache-hit tokens: the reused portion that is fully identical to the prefix of a previous request. The unit price is usually far lower than regular input.
- Output tokens: content generated by the model, generally priced highest.
- Cache writes: some platforms bill cache writes separately, and the cost may depend on the cache’s validity period.
Monthly cost can be estimated with the following formula:
Monthly cost = Σ (monthly volume of a token type × its unit price) × batch discount factor + subscription fee + other surcharges
The monthly token volume is determined by four variables: daily request count, average input length, cache hit ratio, and average output length. A change in any of these variables changes the bill. When estimating costs, collect real logs first to obtain these four values, then plug them into the formula.
3. Prefix Caching: The Most Overlooked Cost Variable
Prefix caching means the platform reuses content at the beginning of requests that is identical across calls, avoiding recomputation. System prompts, fixed tool definitions, long reference documents, and few-shot examples are all common reusable prefixes.
Understanding caching requires attention to three aspects.
(1) Trigger conditions. Most platforms require the prefix to match token-by-token exactly. If a single extra space or timestamp appears earlier in the request, everything after it fails to hit the cache. Some platforms enable caching automatically, while others require explicit declaration.
(2) Validity period. Cache entries expire after a period of inactivity. A common validity window is a few minutes; some billing plans support longer windows at a higher write cost. If the interval between business requests exceeds the validity period, the hit ratio drops quickly.
(3) Billing method. Cache hits are usually charged at a low hit price, while writes may be billed separately. Whether caching is worthwhile depends on computing both the write cost and the hit savings.
At the engineering level, you can improve the hit ratio by adjusting the message structure:
# Recommended: stable content first, dynamic content lastmessages = [{"role": "system", "content": SYSTEM_PROMPT}, # long-term fixed{"role": "user", "content": static_knowledge}, # reused within the same batch{"role": "user", "content": user_query}, # different on every request]# Not recommended: putting dynamic fields such as timestamps# or request IDs at the front makes every request prefix different,# so the cache can never hit
4. Batch Processing: Trading Latency for Price
Batch processing means submitting a large volume of requests as asynchronous jobs that the platform executes within a given time window, billed at a discount below real-time rates. Discount levels vary by platform and model; refer to the official pricing page for details.
Scenarios suited to batch processing include:
- Offline data annotation and cleaning
- Bulk summarization of historical documents
- Model evaluation and regression testing
- Periodic generation of knowledge bases and reports
User-facing real-time conversations and customer-service features that require immediate feedback are not suitable for batch processing. If real-time requests are mistakenly routed into the batch channel, users wait too long and the experience degrades noticeably.
In practice, you can split traffic by latency requirements: interactive requests go through the real-time channel, while everything else enters the batch queue. This kind of routing is usually more sensible than applying a one-size-fits-all policy to all requests.
5. Free Quotas and Subscription Plans
When new models launch, platforms often provide a certain amount of free quota. Such quotas usually have a short validity period, apply only to selected models, and fall back to pay-as-you-go once exhausted. When planning, teams should confirm whether the quota is counted per account, per project, or per organization, to avoid underestimating usage when multiple projects share the same quota.
Subscription plans convert variable costs into fixed costs. Common terms include:
- The range of models covered
- Usage caps or concurrency limits per billing cycle
- Scheduling rules for different time slots, e.g., priority guarantees in some periods and throttling in others
- Whether usage beyond the plan falls back to pay-as-you-go billing
If your workload is stable and high-volume, a subscription plan may be more cost-effective. If usage fluctuates heavily, or requests cluster in throttled time slots, pay-as-you-go billing combined with batch processing is usually easier to control.
6. Model Iteration and Retirement Risk
Model versions are continuously updated,
