LLM API Pricing: From Token Rates to Total Business Cost
Evaluating LLM API pricing requires more than comparing token rates. This article explains how input, output, caching, retries, model selection, and operational overhead affect the cost of completing a task that meets business requirements. It provides cost formulas, a sample budget, and practical guidance for balancing quality, predictable spending, and reliable operation.
1. Start by Defining What You Are Paying For
LLM API pricing appears straightforward: multiply input and output token counts by their respective rates. In production, however, identical API rates can lead to very different business costs.
A short text classification request may return only a few labels, while a report-generation task may produce thousands of tokens or more. Even with the same model, these workloads have different cost structures. The first may be dominated by input costs; the second may spend most of its budget on output.
Evaluating whether a model is expensive therefore requires answering three questions:
- Are the unit rates reasonable? Do input, output, and cached-input rates fit the budget?
- Is task completion cost-effective? Can the model deliver an acceptable result with fewer calls?
- Are operating costs controllable? Could high concurrency, long contexts, or unexpected retries amplify spending?
The meaningful comparison is not the advertised rate in isolation. It is the total cost of completing a business task that meets defined acceptance criteria.
2. Build a Consistent Token Cost Model
Tokens are the basic units used to measure text processed by a model, but they are not equivalent to characters or English words. Language, text format, and tokenization can all affect actual counts. Whenever possible, use usage data returned by the API or an estimation method compatible with the target model.
For a pricing model that distinguishes uncached input, cached input, and output:
Cost per call = (Uncached input tokens × Uncached input rate + Cached input tokens × Cached-input rate + Output tokens × Output rate) ÷ 1,000,000
All rates must use the same currency and be expressed per million tokens.
This formula highlights an important distinction: input tokens do not always have the same rate, and an input cache hit does not eliminate output charges.
When evaluating pricing, also verify:
- Whether all billing components use consistent units.
- Whether displayed prices include taxes or additional service fees.
- How caching is measured and whether cache writes, reads, or storage incur charges.
- Whether minimum billing increments, batch discounts, or other billing methods apply.
- Whether internal reasoning tokens are billed and which billing category includes them.
- Whether discounts are temporary and whether the budget depends on them.
Use the selected provider’s official documentation to confirm these rules. A common billing approach should not be treated as a universal standard.
3. Cache Discounts Do Not Equal Total Cost Savings
Repeated context is a significant cost source in many applications. A customer support assistant may include the same service policies in every request. Code reviews may repeatedly send project constraints, while question-answering systems may reuse a fixed response format.
If a provider offers discounted cached-input pricing, this repeated content may become less expensive.
Let:
- I be the total number of input tokens.
- h be the cache hit rate measured by token volume.
- Pᵤ be the uncached-input rate.
- P꜀ be the cached-input rate.
Then:
Input cost = I × [(1 − h) × Pᵤ + h × P꜀] ÷ 1,000,000
The hit rate must be measured by token volume, not simply by the number of requests with a cache hit. A hit covering a few dozen tokens has a different billing impact from one covering several thousand.
Suppose cached input costs 20% of the uncached rate and the token-based hit rate is 80%. The effective input rate becomes:
20% × Full rate + 80% × 20% × Full rate = 36% of the full rate
Input costs fall by 64%, but the cost of the entire call does not necessarily fall by 64%.
If input previously accounted for 30% of total cost and output accounted for the remaining 70%, the total reduction would be approximately:
30% × 64% = 19.2%
A cached-input rate that is one-fifth of the uncached rate does not mean the application will cost one-fifth as much. Savings depend on the input share of spending, the amount of reusable content, and actual cache hits.
4. Which Workloads Benefit Most from Caching?
Applications with Extensive Fixed Instructions
Applications with long system prompts, response guidelines, and business constraints often have substantial context-reuse potential.
Separate stable content from dynamic content. Keep fixed instructions consistently versioned, and place user questions and live business data in the dynamic portion. For prefix-based caching mechanisms, this organization generally supports reuse.
However, matching rules, expiration periods, and minimum cacheable lengths vary. Similar-looking text does not guarantee a cache hit. Verify reuse through actual usage measurements.
Multi-Turn Conversations
Multi-turn conversations often resend historical messages, so input volume grows as the conversation continues. Caching may reduce the cost of repeated history, but it does not solve unlimited context growth.
Combine caching with context management:
- Retain recent messages relevant to the current task.
- Convert older content into structured summaries.
- Store key facts that require long-term memory separately.
- Remove duplicate, outdated, or clearly irrelevant information.
Summarization can lose details and adds its own API costs. Decide whether to compress history based on conversation length, expected future reuse, and accuracy requirements.
Retrieval-Augmented Generation
Retrieval-augmented generation (RAG) supplies external material to a model, but that material may not repeat consistently. Changes in retrieved content, ordering, or assembly can affect cache reuse.
Using RAG does not automatically imply a high cache hit rate. Measure reuse separately for fixed prompts, conversation history, and retrieved passages to identify the parts that can actually be optimized.
5. Long Context Is a Capacity Limit, Not a Free Resource
A larger context window can accommodate more documents, conversation history, and task material. It represents a capacity limit, not a recommendation to fill that limit on every request.
Sending large amounts of material can create three problems.
First, input costs increase. Even with cache discounts, initial submissions and uncached portions can generate substantial charges.
Second, latency may increase. The effect depends on the model and service implementation, but longer inputs generally require more processing. Long context should not be assumed to have no performance cost.
Third, useful information becomes less concentrated. More material does not necessarily make the correct evidence easier to find. Duplicate passages, outdated rules, and conflicting information may increase answer errors.
A sound context strategy provides the information needed to complete the task, rather than everything available. For long-document tasks, locate relevant sections before analyzing them in detail. Expand the scope when cross-document synthesis is genuinely necessary.
Treat maximum output length the same way. It is a permitted upper bound, not a target for every response. Clear requirements for format, fields, and length can reduce unnecessary output, but cost controls should not truncate explanations or business results needed to complete the task.
6. Validate Model Tiers Through Task-Based Routing
Offering lightweight and higher-capability model tiers is a common way to allocate resources. However, an expensive tier is not appropriate for every task, and a cheaper tier does not necessarily produce a lower final cost.
Format conversion, simple classification, and information extraction under explicit rules are good candidates for testing lower-cost options first. Complex code analysis, cross-document reasoning, and high-risk business decisions may require stronger models or additional human review.
A practical tiered-routing workflow is:
- Select an initial model based on task type, input complexity, and risk.
- Validate the output through format checks, business rules, or tests.
- Escalate to a stronger model or a human workflow if validation fails.
- Record the escalation rate, final success rate, and total task cost.
Savings are not guaranteed. If the cheaper model frequently fails, repeated calls and resubmitted context may erase its unit-price advantage.
Do not rely solely on a model’s self-reported confidence to decide whether to escalate. More reliable signals include structured-field completeness, compliance with business rules, sufficient supporting evidence, and executable test results.
7. Compare Cost per Accepted Task, Not Just API Rates
A successful API response means the request returned a result. It does not prove that the business task was completed.
Define acceptance criteria before evaluating models. For example:
- Does information extraction include all required fields?
- Does a code change pass the necessary tests?
- Does a customer support reply comply with business policies?
- Does document analysis provide verifiable evidence?
- Does generated content require substantial manual rework?
Then calculate:
Cost per accepted task = Total relevant spending during evaluation ÷ Number of tasks completed to the required standard
Depending on the evaluation scope, total spending should include not only model calls but also retrieval, storage, networking, logging, human review, and rework.
The test set should include typical workloads, long inputs, edge cases, and historical failures—not just easy examples. Apply the same quality standards to every option. Otherwise, an apparent cost advantage may simply reflect weaker acceptance criteria.
8. Use a Sample Budget to Identify Cost Drivers
The following figures illustrate the calculation method only. They do not represent any actual provider’s prices. All amounts are in Chinese yuan (CNY).
Assume an application averages:
- 10,000 input tokens per request.
- 1,000 output tokens per request.
- CNY 2 per million uncached-input tokens.
- CNY 0.4 per million cached-input tokens.
- CNY 8 per million output tokens.
- A 60% input-token cache hit rate.
Input cost per call is:
10,000 × (40% × 2 + 60% × 0.4) ÷ 1,000,000 = CNY 0.0104
Output cost per call is:
1,000 × 8 ÷ 1,000,000 = CNY 0.008
The total is approximately CNY 0.0184 per call. At one million calls per month, model-call spending would be approximately CNY 18,400, excluding retries and other system costs.
If output length doubles while everything else remains unchanged, the cost per call rises to CNY 0.0264.
This illustrates a key sensitivity: when output already represents a substantial share of spending, further input-cache optimization cannot replace management of output length and task workflows.
9. Maintain Cost Controls After Deployment
Budget estimates are only a starting point. Production request patterns change over time. Monitor at least:
- Input, output, and cache-hit token counts per request.
- Average and high-percentile costs by workload type.
- Failure rates, retry rates, and model escalation rates.
- Cost per accepted task.
- Response latency and changes in quality.
- Budget consumption by user, session, or business module.
Set limits for unusually long inputs, unusually long outputs, and repeated retries. Configure reasonable maximum iteration counts for automated tasks so that error loops cannot keep consuming the budget.
Caching must also meet security requirements. For personal information or sensitive business data, verify retention practices, access isolation, and applicable policies. Do not mix private context across users merely to increase reuse.
10. Balance Quality, Cost, and Reliability
LLM API pricing should not be judged solely by a low token rate or a price increase in a premium tier. A more reliable assessment considers input, output, caching, retries, quality, and engineering overhead within the same framework.
For developers, the first priorities are to establish token-level measurement, verify cache savings, remove unnecessary context, and match model capability to task difficulty. Enterprises should also account for manual rework, business risk, and service reliability.
The best option is not necessarily the one with the lowest advertised price. It is the one that completes business tasks at a predictable, sustainable total cost while meeting quality and security requirements.
