How to Evaluate LLM Costs and Choose Models After an API Price Change
LLM model selection should not be based on token prices alone. This article explains how to estimate the average cost per successful task, analyze billing structures, use production logs to forecast usage, manage price changes, route tasks across model tiers, and evaluate cost alongside quality. It also provides practical engineering guidance for monitoring usage, controlling budgets, and maintaining flexibility across model providers.
1. Token Prices Alone Should Not Determine Model Selection
Large language model services typically charge by token. For the same model, input and output tokens often have different prices, with output tokens generally costing more. Looking only at the advertised price per million tokens can therefore lead to misleading conclusions.
Actual costs are determined by three factors:
- Tokens consumed per request, including input, output, and any reasoning tokens that may be billed.
- Total request volume, based on the number of calls made each day or month.
- Retry and manual correction costs, incurred when the model produces an unacceptable result and requires another call or human rework.
The more useful metric is the average cost per successful task, rather than the listed token price. A low-cost model with a high error rate may ultimately be more expensive than a higher-priced model that delivers reliable results.
2. Break Down the Billing Structure
Billing rules vary significantly between providers. Before selecting a model, review each of the following dimensions.
- Separate input and output pricing: In long-context scenarios, input tokens may account for most of the usage, making the input price especially important.
- Cache hits and misses: Stable system prompts and fixed document prefixes can often be reused through caching. Cache hits are usually priced much lower than cache misses, but caching rules, retention periods, and billing methods vary by service.
- Reasoning tokens: Models that support extended reasoning may generate additional intermediate tokens. These tokens may also be billable and must be included in cost estimates.
- Tiered or time-based pricing: Some services use different price tiers based on context length or usage periods.
- Pay-as-you-go pricing versus subscription plans: Subscription plans commonly include quotas, rate limits, and usage terms. In high-frequency workloads, the practically usable capacity may be lower than the theoretical quota.
The following function can be used to estimate daily costs:
def estimate_daily_cost(requests, avg_input, avg_output, cache_hit_rate,price_input, price_cache_hit, price_output):"""All prices are per-token rates. Returns the estimated daily cost.cache_hit_rate is the proportion of input tokens served from cache,with a value between 0 and 1."""cached_tokens = avg_input * cache_hit_rateuncached_tokens = avg_input - cached_tokensper_request = (uncached_tokens * price_input+ cached_tokens * price_cache_hit+ avg_output * price_output)return requests * per_request
The key idea is to divide input tokens into cached and uncached portions and apply the corresponding prices. When combined with production logs, this approach can provide a reasonably accurate budget forecast.
3. Estimate Usage from Production Logs
Relying on subjective impressions when estimating usage can introduce significant errors. A more reliable approach is to sample real requests and measure the following:
- Average input and output length, preferably broken down by task type.
- Cache hit rate, obtained from usage information returned by the service.
- Average number of model calls per task.
Agentic workloads, in which a model calls tools, reads the results, and continues reasoning across multiple turns, can multiply token consumption. A task that appears simple may trigger more than a dozen model calls. The number of calls must be included in the estimate; otherwise, the budget will be substantially understated.
It is useful to create usage profiles for different scenarios, such as code retrieval, batch summarization, multi-turn conversations, and automated agents. Price sensitivity can vary significantly across these scenarios, so they should be calculated separately.
4. Plan for Price Changes
Pricing cycles can be short, so historical prices should be treated as reference data rather than a long-term basis for planning. Teams can take the following measures:
- Run price-sensitivity tests: Assume that prices increase by a given percentage or that the cache hit rate declines, then check whether the budget remains acceptable.
- Set cost thresholds: Define a monthly budget limit for each project. When the limit is exceeded, trigger alerts or fallback strategies.
- Avoid dependence on a single provider: Use a unified model-calling abstraction layer to connect multiple models, so switching providers or models only requires configuration changes.
5. Use Tiered Model Routing
Not every task requires the most capable model. A practical approach is to route tasks according to their difficulty:
- Use lightweight models for simple classification, format conversion, keyword extraction, and similar tasks.
- Use general-purpose models for routine question answering, document summarization, and code completion.
- Use high-capability models for complex reasoning, architecture design, and critical code review.
The following is a simplified routing example:
TASK_TIER = {"classify": "light","summarize": "general","code_review": "advanced",}MODEL_BY_TIER = {"light": "model-light-v1","general": "model-general-v1","advanced": "model-advanced-v1",}def pick_model(task_type: str) -> str:tier = TASK_TIER.get(task_type, "general")return MODEL_BY_TIER[tier]
In production projects, model names should be stored in configuration files so they can be replaced without changing application code.
6. Evaluate Cost Efficiency with Quality as a Constraint
Cost optimization should not come at the expense of quality. Teams should establish a consistent evaluation set that includes:
- A representative collection of inputs covering major task types and edge cases.
- Accuracy, format compliance, response latency, and per-task cost for each candidate model.
- The same inputs and scoring standards for every model being compared.
The key metric should be the cost per task that passes evaluation. This reflects the combined impact of pricing, quality, and retry rates.
7. Engineering Recommendations
- Build a unified model gateway: Business applications should depend only on an internal interface, while model names, pricing tables, and routing rules remain in configuration.
- Record usage and spending daily: Aggregate data by project, model, and task type, and connect it to monitoring and alerting systems.
- Optimize prompt structure: Place stable system instructions and reference materials at the beginning of the prompt to improve the likelihood of prefix-cache hits.
- Implement budget circuit breakers: When a budget limit is reached, automatically downgrade to a lower-cost model or pause non-critical tasks.
- Review compliance and procurement terms: Confirm invoice requirements, service agreements, data-retention policies, and usage restrictions with procurement and legal teams before signing a contract.
8. Conclusion
LLM model selection is an ongoing process. Model prices, caching rules, and subscription terms can change quickly, so teams need a repeatable evaluation method: use real logs to estimate usage, apply consistent benchmarks to measure quality, use tiered routing to control costs, and rely on monitoring and circuit breakers to keep budgets under control.
Once this process is standardized, teams can quickly reassess their options and make informed decisions whenever pricing or service terms change.
