Token Pricing Explained: The Cost Logic Behind LLM API Bills
This article breaks down how large language model token pricing is actually calculated, starting from GPU rental cost per hour and working up to the final bill. It explains the key constraints that determine cost—memory capacity, parallelism strategy, batching, and caching—why input and output tokens are priced differently, and why a service that looks cheap on paper can still be expensive in practice. Developers will also find a practical checklist for reducing token spend through prompt compression, cache hit optimization, model routing, and off-peak batching.
1. What a Rare Public Cost Breakdown Revealed
In March 2025, a model team did something almost no one in the industry had done: it published the complete cost and revenue structure of its online inference service on a code hosting platform. The math was straightforward. Assuming a rental rate of $2 per GPU per hour, the total daily compute spend came to roughly $87,000. If every call were billed at standard pricing, theoretical daily revenue would be about $562,000. Dividing the two yields roughly 6.45x—in other words, 545% of headroom above cost, or more than $200 million annualized in theory.
The same disclosure then poured three buckets of cold water on that number. The web and mobile endpoints are free, so a large share of traffic generates no revenue and is pure cost. Smaller, cheaper models absorb a portion of requests, pulling the average price per call down. And off-peak discounts are offered at night, because idle GPUs burn money too—discounting to fill capacity beats leaving it unused. The real margin is far below 545%.
The true value of this material is not “how much was made,” but that it proved one thing for the first time: token prices are not arbitrary. They can be derived step by step from “how much a GPU costs per hour” down to several decimal places. The rest of this article follows that chain from the bottom up.
2. The Foundation: Compute Is Billed by Time
LLM inference runs on specialized accelerator cards, not consumer GPUs. Taking the 80GB-class card assumed in the disclosure as an example, public rental listings sit at roughly $2 per hour. For the higher-tier 80GB flagship card, quotes across vendors range from $1.4 to $3.1, with extreme cases reaching $7.5—the same model can differ by more than 20x across platforms. The median for 141GB high-memory cards is about $3.4, while the latest generation sits in the $5 to $18 range, with a clear premium.
One key point has to be established here: GPUs are billed by time, regardless of whether you fully utilize them. Send a request containing only 20 tokens, and the card is still metering by the hour. So the first-principles formula for per-token cost is very simple:
Cost per token = GPU rental per hour / (Tokens produced per GPU per hour)
The denominator is where all the competition happens. Whoever can make the denominator larger can push the price down.
3. Layer Two: Memory Capacity Determines How Much You Can Compute at Once
Many people assume compute (FLOPS) is the bottleneck. In practice, during inference, memory capacity and memory bandwidth tend to hit the wall first.
Here is a rough but useful estimate: in the decode phase, generating each token requires reading the model weights and the KV Cache across memory in full. If a card has 80GB of memory and the model weights take 40GB, only about 40GB is left for the KV Cache, which directly caps the number of concurrent requests and the maximum context length.
Available KV space ≈ Total memory - Weight footprint - Framework and fragmentation overheadMax concurrency ≈ Available KV space / KV footprint per requestKV footprint per request ∝ layers × KV heads × head dimension × sequence length × bytes per precision
The conclusion is hard and clear: the longer the context and the higher the concurrency, the tighter memory becomes and the more expensive each token gets. This also explains why long-context capability is usually a premium feature.
4. Layer Three: The Trade-off Between Parallelism Strategy and Throughput
When a single card cannot hold the model, you need tensor parallelism, pipeline parallelism, or expert parallelism. Raising the degree of parallelism makes it possible to fit a larger model, but it introduces communication overhead. The number of cards goes up, yet the denominator does not necessarily scale proportionally. The engineering rule of thumb is that parallelism is not “the higher the better”—there is an optimal throughput point, and beyond it the cost per token climbs again.
5. Layer Four: Batching and Caching, the Real Amplifiers of the Denominator
The core technique for inference throughput is continuous batching: pack multiple requests into a single batch so the GPU always has work to do. Combined with paged KV management to reduce memory fragmentation, the number of tokens produced per GPU per hour can increase several-fold. This is the main reason prices can keep falling.
The other amplifier is cache reuse. When a prefix cache hits, that portion of computation can be skipped entirely:
Billed tokens = Input tokens × (1 - cache hit rate) + Output tokensHigher hit rate → effective compute drops sharply → lower cost per token
System prompts, long document templates, and multi-turn conversation history are all high-hit scenarios.
6. Layer Five: Why Input and Output Are Priced Differently
The output phase is token-by-token autoregressive generation: serial, memory-access intensive, and impossible to parallelize. The input phase can be processed in parallel all at once, with far higher compute utilization. As a result, the output price is usually several times the input price. This is not a pricing strategy but a direct mapping of the cost structure.
7. Layer Six: From Cost to Bill
Putting the layers above together, the bill is roughly this function:
Cost = (Input tokens × Input price) + (Output tokens × Output price) - Cache discount - Off-peak discountWhere unit price ≈ (GPU rental + Operations + Networking and storage + Redundancy buffer) / Effective throughput tokens
Note that the numerator contains more than GPU rental. It also includes the engineering work you cannot see: amortized infrastructure such as monitoring and alerting, logging services, object storage, message queues, and container platforms, plus the redundant capacity reserved to absorb traffic spikes. Redundancy is a cost, and it is also how availability is priced.
8. Why “It Looks Cheap” but Still Costs a Lot
Three structural reasons. First, free traffic dilutes revenue and must be subsidized by paid calls. Second, the gap between peak and trough traffic is enormous—provisioning for the peak while charging for the average is a structural loss. Third, the larger the model and the longer the context, the harder it is to grow the denominator. Off-peak discounts are precisely the hedge against the third point: selling idle compute at a discount at night is worth doing as long as marginal revenue is greater than zero.
9. A Cost-Reduction Checklist for Developers
- Compress input: trim prompts and retrieved snippets; summarize long documents before feeding them to the model.
- Improve cache hit rate: keep the system prompt prefix fixed and maintain stable templates.
- Tiered routing: send simple requests to small models and escalate only complex ones.
- Control output length: set a reasonable maximum generation length and use structured output constraints.
- Off-peak batching: move offline jobs to low-traffic windows and make non-real-time pipelines asynchronous.
- Observability first: use monitoring and logs to attribute token consumption by business dimension and find the real cost black holes.
10. Conclusion
The essence of token pricing is dividing “time-based rent” by “effective throughput.” Once you understand the four levers—memory constraints, batching, caching, and off-peak scheduling—you can forecast the bill at the architecture design stage instead of getting educated by it at the end of the month. In practice on platforms such as Baidu AI Cloud, this cost model is also a foundational tool for capacity planning and service pricing.
