Cost Modeling for LLM APIs: Cache Discounts and Tiered Scheduling in Practice
This article explains why LLM API bills often diverge from expectations based on public price cards, covering three root causes: inconsistent billing units, asymmetric input/output pricing, and cache-driven cost changes. It provides a structured approach to aligning pricing terms before comparison and introduces a per-call cost model that separates regular input tokens, cached input tokens, and output tokens. A practical framework helps teams perform reproducible cost estimation before selecting a model or service.
Why Cost Modeling Must Start with Billing Rules
Many teams compare only the published unit prices when selecting a model service, only to find that the final bill differs significantly from what they expected. The gap usually comes from three sources.
First, billing units are inconsistent across providers. Some services charge by token, while others bill by credits, requests, or duration. These units have no fixed conversion ratio, making direct side-by-side comparison impossible.
Second, input and output prices are asymmetric. The unit price for generated output tokens is typically much higher than for input tokens. Given the same total token count, a higher output ratio leads to higher overall cost.
Third, cache hits change the effective unit cost. When identical prefix content is reused across calls, the billing for the cached portion may drop significantly. Standard price cards usually do not reflect this.
Therefore, cost modeling should start from the billing rules and break down each API call into individually measurable components.
Align the Basis Before Comparing
Before running any numbers, verify the following items.
- Use the same billing unit for all options within a single comparison.
- Check whether the conversion ratio between credits and currency is fixed. If it varies with subscription tier or promotions, record the point in time at which the conversion was made.
- For services billed per request, first estimate the average number of tokens consumed per call before comparing with token-based pricing.
- For services billed by duration, record the statistical window and concurrency level. Otherwise, the call volume corresponding to the same duration cannot be aligned.
- Price card versions and effective dates matter. The cost result must specify which version was used, or it cannot be reproduced.
Per-Call Cost Model
The cost of a single API call can be expressed as:
Cost = Regular Input Tokens × Input Unit Price + Cached Input Tokens × Cache Unit Price + Output Tokens × Output Unit Price
This formula relies on two premises. First, regular input tokens and cached input tokens are mutually exclusive. Once a portion of the prompt is counted as a cache hit, it must not be billed again as regular input. Confirm the exact accounting rule with the service provider’s documentation. Second, check whether cache write or cache storage incurs an additional charge. If so, add the write cost, calculated as write unit price multiplied by the number of tokens written.
The following is a hypothetical example to illustrate the calculation method. Assume a price card with an input unit price of 10, a cache unit price of 2, and an output unit price of 40, all using the same billing unit as defined in the card.
