LLM Pricing Changes: How to Evaluate Real Costs and Value
Evaluate LLM pricing changes by measuring cost per successfully completed task, not just price per million tokens. This guide explains token billing, caching, retries, subscription comparisons, and a reusable Python cost calculator, along with engineering practices for reducing costs without compromising task quality.
1. Why Price Changes Require a Fresh Evaluation
When large language model providers change their prices, discussions often focus on the new unit rates. Those rates matter, but they do not directly determine what developers actually spend. Actual spending depends on three factors: token consumption per task, the billing model, and the frequency of failures and retries.
A severalfold increase in token prices does not necessarily mean a proportional increase in cost per task. If a new model completes the same work in fewer reasoning steps or achieves a higher cache hit rate, the total cost may change little. Conversely, even a small price increase can substantially raise costs if the model produces longer responses or requires more calls.
The key question is therefore:
What is the average cost of completing a business task successfully?
2. Understand the Components of Token-Based Billing
Most LLM APIs charge by token usage. Common billing categories include the following.
Uncached input tokens
System prompts, conversation history, retrieved documents, and user questions all count toward input usage. Input can be a major cost component, especially in long-context applications.
Cached input tokens
When a request shares a prefix with recent requests, the provider may reuse previously computed intermediate results and charge a lower rate for the cached portion. Cached input rates are often substantially lower than standard input rates, making prefix reuse a direct way to reduce costs.
Output tokens
Generated content counts toward output usage. Many providers charge more for output than input, so response length can have a significant effect on the bill.
Reasoning tokens, where applicable
Some models generate internal reasoning before returning an answer. These tokens are often billed as output, even though their text is not visible to the user. Looking only at the visible response length can therefore underestimate actual usage.
3. Unit Prices Do Not Tell You the Cost per Task
The same token rates can produce very different bills across applications. Several factors explain the difference:
- Task complexity: Simple question answering may require only one or two calls. Code repair or multistep analysis may involve multiple rounds of tool use, with context included again in each request.
- Context length: Conversation history is typically sent again with each request. Without summarization or truncation, per-request input costs can grow roughly with the number of conversation turns.
- Failures and retries: Invalid output formats, tool errors, and timeout retries can add charges. Failed calls can still incur costs.
- Model selection: Assigning simple subtasks to a more capable but more expensive model can inflate spending.
When comparing models, measure cost per successfully completed task, not just price per million tokens.
4. Convert Subscription Budgets into Comparable Task Volumes
Subscription plans often describe allowances as request counts or usage ranges, such as a monthly request limit or an equivalent spending allowance. These figures are difficult to compare directly with pay-as-you-go pricing.
Use the following process to establish a task-based comparison:
- Select a representative sample of real tasks from your application. A starting sample of 50–200 tasks is often sufficient.
- Record input tokens, cached input tokens, output tokens, and the number of calls for each task.
- Calculate the average task cost using pay-as-you-go rates.
- Divide the subscription price by that average cost to estimate how many tasks the same budget would cover under pay-as-you-go billing.
This provides a budget-equivalent task count, not a guarantee of how many tasks a subscription will allow. The plan’s actual usage rules still apply.
The result also depends heavily on the task mix. A sample dominated by simple tasks can make a plan appear highly economical, while long-context or reasoning-heavy tasks can lead to the opposite conclusion. Include the long tail of difficult tasks so the sample reflects real traffic.
5. A Reusable Cost Calculation Framework
The following Python code provides a general framework for calculating token costs. Replace the placeholder rates with the provider’s official prices, using one consistent currency throughout.
from dataclasses import dataclass@dataclassclass TokenPricing:"""Rates per million tokens, in a consistent currency."""input_per_m: float # Uncached inputcached_per_m: float # Cached inputoutput_per_m: float # Output, including reasoning tokens if billed here@dataclassclass CallUsage:input_tokens: int # Total input tokens for this requestcached_tokens: int # Cached portion of the inputoutput_tokens: int # Billable output tokensdef call_cost(pricing: TokenPricing, usage: CallUsage) -> float:fresh = usage.input_tokens - usage.cached_tokensif fresh < 0:raise ValueError("cached_tokens cannot exceed input_tokens")return (fresh * pricing.input_per_m+ usage.cached_tokens * pricing.cached_per_m+ usage.output_tokens * pricing.output_per_m) / 1_000_000def task_cost(pricing: TokenPricing, calls: list[CallUsage]) -> float:"""A task may require multiple calls; sum their costs."""return sum(call_cost(pricing, c) for c in calls)def tasks_per_budget(avg_task_cost: float, budget: float) -> int:if avg_task_cost <= 0:raise ValueError("Average task cost must be greater than zero")return int(budget // avg_task_cost)
Example calculation
The following rates are hypothetical and do not represent any provider’s actual pricing.
Suppose a request contains:
- 50,000 input tokens, including 40,000 cached tokens
- 3,000 output tokens
- Rates of CNY 4 per million uncached input tokens, CNY 0.4 per million cached input tokens, and CNY 16 per million output tokens
The cost is:
| Component | Calculation | Cost |
|---|---|---|
| Uncached input | 10,000 × 4 / 1,000,000 | CNY 0.040 |
| Cached input | 40,000 × 0.4 / 1,000,000 | CNY 0.016 |
| Output | 3,000 × 16 / 1,000,000 | CNY 0.048 |
| Total | CNY 0.104 |
The example illustrates why cache hit rate and output length can matter more than headline token rates alone.
6. Engineering Practices for Reducing Cost per Task
Once you have measured costs, use engineering changes to reduce them. The following practices apply to many LLM applications.
Keep request prefixes stable to improve cache reuse
Place system prompts, tool definitions, and fixed examples at the beginning of the request, followed by changing user content. A stable prefix improves the opportunity for cache hits.
Avoid putting timestamps, random IDs, or other values that change on every request into the reusable prefix.
Control conversation history
Multiturn conversations do not always need the complete message history. Use rolling summaries and retain recent turns alongside essential facts.
This reduces input costs and lowers the risk that irrelevant context will distract the model.
Constrain output length
Use explicit formatting requirements and length limits to reduce unnecessary explanatory text. For structured output, use JSON Schema or an equivalent constraint mechanism where available to reduce parsing failures and retries.
Route tasks by difficulty
Smaller, less expensive models can handle simpler subtasks such as classification, extraction, and format conversion. Reserve higher-priced models for tasks that require more complex reasoning.
Validate routing rules against a small labeled sample before deployment to check that quality remains acceptable.
Set budgets and alerts
Define daily spending limits for each feature and cost thresholds for individual tasks.
A sudden increase in average task cost may indicate prompt changes, growing context, or a retry storm. Investigate these changes promptly.
def should_alert(recent_costs: list[float], baseline: float, factor: float = 1.5) -> bool:"""Alert when recent average task cost exceeds baseline times factor."""if not recent_costs:return Falseavg = sum(recent_costs) / len(recent_costs)return avg > baseline * factor
7. Common Evaluation Mistakes
- Comparing prices without measuring usage: A model with higher token rates may cost less overall if it completes the task in one attempt.
- Relying on benchmarks instead of application metrics: General benchmark scores do not necessarily predict accuracy or format compliance in your application. Use your own test set.
- Ignoring failed calls: Failed requests can still incur charges and increase user waiting time.
- Using averages without examining the distribution: A small number of exceptionally long tasks may account for a large share of spending. Track the median and high percentiles as well as the mean.
- Treating subscription allowances as permanent guarantees: Plan rules may change. Check the provider’s latest published terms before making a decision.
8. Implementation Checklist
- Collect representative tasks for each application feature and record actual token usage.
- Build comparison tables around cost per successfully completed task, rather than unit token prices alone.
- Calculate the cost shares of uncached input, cached input, and output to identify the main spending drivers.
- Optimize stable prefixes and history truncation, then monitor changes in cache hit rate.
- Test model routing for simple subtasks and use quality metrics to determine whether the trade-off is acceptable.
- Monitor cost per task, configure alerts, and review the results regularly.
