How to Estimate the Real Cost of LLM Tokens: A Practical Guide
A practical guide to estimating the true cost of LLM tokens beyond advertised API prices. It breaks down API pricing variables, subscription plan conversion, prompt caching impact, and task success rates, then outlines a measurement workflow and routing strategy to avoid the trap of the lowest unit price with the highest bill.
How to Estimate the Real Cost of LLM Tokens: A Practical Guide
1. Where the Problem Starts: A Cheap Unit Price Is Not a Cheap Bill
When choosing a large language model, almost everyone looks first at the pricing page: how much per million input tokens, how much per million output tokens. Across the industry, the API unit price of leading Chinese models is typically only 30% to 60% of top overseas models, and lightweight models can drop below 3% of a mid-tier overseas model. Judging from that table alone, the conclusion seems beyond dispute.
Switch the view to the individual subscription market, however, and the conclusion nearly reverses. One media test found that a smart coding subscription package costing roughly 1,300 RMB per month works out to about 12 to 14 RMB per 100 million tokens once the estimated monthly usage is applied. Several subscription packages launched by domestic platforms over the same period ranged from just over 6 RMB to 100 RMB per 100 million tokens; only the cheapest tier was clearly better than the subscription option, while most were actually more expensive.
This is not a data error. “List price” and “actual cost” are simply two different sets of books. Making the right decision requires breaking cost into layers that can actually be calculated.
2. Layer One: What Makes Up an API Price, and the Traps Inside It
API billing looks transparent, but it involves at least five variables:
- Input and output are priced separately: the output token price is usually several times the input price, so the cost of long-form generation is driven mainly by output.
- Cache read/write differences: input tokens that hit the cache are heavily discounted, while the rest are charged at full price.
- Context length tiers: some models price extra-long context separately.
- Concurrency and rate limits: retries caused by rate limiting are billed again.
- Failed requests: most platforms still charge for output that was generated, so calls that fail to parse or return the wrong format are money spent for nothing.
A schematic cost estimation logic can be written as:
def estimate_cost(in_tok, out_tok, cached_in,price_in, price_out, cache_discount=0.1):# cached_in is the number of input tokens that hit the cachefresh_in = max(0, in_tok - cached_in)return (fresh_in * price_in+ cached_in * price_in * cache_discount+ out_tok * price_out)
What really determines the bill is the actual value of those four parameters in your business, not the numbers on the pricing page.
3. Layer Two: How to Convert a Subscription Package
The core logic of a subscription is “trading a fixed monthly fee for a usage ceiling.” The vendor’s return rests on two assumptions: heavy users subsidized at a low price bring ecosystem and word-of-mouth benefits, and most ordinary users never come close to exhausting their quota, with actual consumption possibly under 10% of the cap.
Converting the real unit price of a subscription therefore takes three steps:
- Measure real usage: record input, output, and cache-hit token counts continuously for two to four weeks, rather than looking at the advertised “quota ceiling.”
- Use actual consumption as the denominator: real unit price = monthly fee ÷ actual monthly consumption (per 100 million tokens). A price calculated from a fully used quota is only a theoretical floor.
- Account for idle cost: a higher tier bought for occasional peaks should have its unused portion counted into the unit cost.
A common mistake is comparing the “quota ceiling” against the API list price, which makes subscriptions look permanently like the better deal. Only when both are converted using measured consumption do the two sets of books become comparable.
4. Layer Three: How Caching Reshapes the Bill
The cache hit rate is the single largest variable in the cost structure of modern LLMs. In testing, long-session smart coding scenarios commonly show a cache share above 90%, with some reaching 97%. The reason is straightforward: the same code repository and the same system prompt are carried into context repeatedly across consecutive turns, and once cached, that portion of input is billed at only a small discount.
Engineering optimizations include:
- Stable prefix: put the system prompt and project description at the very front of the context and avoid frequent changes, maximizing prefix cache hits.
- Avoid meaningless changes: appending a timestamp or random ID after a stable prefix breaks the cache.
- Session reuse: keep follow-up questions on the same task inside one session instead of starting a new one each time.
- Structured trimming: include only relevant file fragments in the context to reduce fresh, uncached input.
Note that caching is implemented differently across platforms and a hit cannot be assumed; keep observing the cache token fields in your bill.
5. Layer Four: Task Success Rate Is the Hidden Denominator
Comparing unit prices alone has one fatal flaw: it assumes every model gets it right on the first try. In reality, the same task may take repeated attempts, and every failed retry is real spending.
In one public evaluation, 20 models were given the same financial report tabulation task over 60 rounds. Nine reached 100% accuracy, six of them Chinese models; the cheapest one cost only about 0.25 RMB per task run, less than 3% of the most expensive model. Two things follow: on low- to mid-difficulty tasks, lightweight models offer extremely high value for money; but on hard tasks such as complex code refactoring or long-standing bugs, the cumulative cost of a weak model’s repeated attempts can exceed the cost of a strong model succeeding on the first pass.
The more reasonable metric is therefore effective cost:
effective cost = total spend ÷ number of tasks that pass acceptance
Add time cost on top: a first-try success saves not only tokens but also waiting time and manual review hours.
6. A Workflow You Can Actually Run
Teams should build a cost baseline in this order:
- Sample by scenario: split the business into simple Q&A, long-form generation, code completion, and complex reasoning, and sample each.
- Record all three token types: input, output, and cache hits, none of which can be skipped.
- Track success rate and retry count: based on manual or automated acceptance.
- Compute effective cost and time to acceptance: producing a unit cost for each scenario class.
- Build a routing policy: send simple requests to lightweight models and escalate complex ones to flagship models.
The routing logic can be simplified as:
def route(task):if task.difficulty <= 2 and task.context_len < 8000:return "light_model" # low-cost tierif task.requires_long_context:return "long_context_model"return "flagship_model" # high-capability tier
Pair this with monitoring, alerting, and logging services, and turn token consumption, cache hit rate, and failure rate into a dashboard; only then does cost optimization have a continuous basis.
7. Why Strategies Differ Between the Two Markets
The divergence between the two market types has clear causes. Leading overseas vendors sit on large-scale funding and are willing to subsidize heavy developers with low-price subscriptions, while betting that most users will not use up their quota. Domestic vendors face greater pressure on compute procurement and payback, so they lean toward low-price APIs to compete for enterprise call volume and have less room for equivalent subscription subsidies. This explains why “cheap API, more expensive subscription” can hold true at the same time. For enterprise procurement, it means consumer-grade packages cannot be copied straight into a budget; the billing model should be chosen according to the real call pattern.
8. Conclusion
The token unit price is only the starting point, not the answer. What actually needs comparing is three things: how much money it takes to get the same thing done, how much time it takes, and whether the result can be used as-is. Putting API list prices, subscription conversion, cache hit rates, and task success rates into a single model is the only way to avoid the trap of “lowest unit price, highest bill.” Baidu AI Cloud’s practice in model services and cost governance confirms the same logic: using real business workloads as the baseline for accounting and routing is what makes cost controllable.
