From Token Pricing to Cost per Task: A Practical Guide to Evaluating LLM APIs
Nominal token prices do not tell the full cost story for large language model APIs. This guide explains how to evaluate cost per task by accounting for token usage, output growth, caching and batch discounts, retries, agent interaction turns, and model quality. It also provides practical cost-control measures, an evaluation framework, and guidance on when self-hosted or hybrid deployments may be more economical.
1. Why Stable Token Prices Do Not Mean Stable Bills
As large language model services evolve, providers often release a new generation of models with significantly better benchmark results while keeping nominal API prices at roughly the same level as the previous generation. This can easily be interpreted as an automatic improvement in cost efficiency. From an engineering budget perspective, however, that conclusion is incomplete.
API billing is based on tokens, but the number of tokens required to complete a real business task is determined by model behavior rather than by the pricing table. As models become better at “thinking”—for example, by using longer intermediate reasoning processes for multi-step analysis, code generation, or long-running tasks—the output length of a single call may increase substantially. If the price per token stays the same while usage increases, the total cost can still rise.
The correct starting point for model evaluation is therefore not the price list, but cost per task: how much it costs, on average, to complete a task with meaningful business value.
2. The Three Layers of LLM Cost
Layer 1: Nominal Token Pricing
Pricing is typically divided into three categories:
- Input tokens
- Output tokens
- Cached input tokens
Output tokens are generally more expensive than input tokens, often by a factor of two to four. This means that any design that increases output length has a stronger impact on the bill than an equivalent increase in input length.
Layer 2: Discount Structures
Most major services provide two common cost-optimization mechanisms:
- Prompt caching: Stable prefixes—such as system prompts, tool definitions, and long documents—can reuse previous computation. Cached portions are billed at a significant discount, with common industry discounts reaching roughly 20% to 30% of the original price.
- Batch processing and asynchronous quotas: Non-real-time workloads can trade higher latency for lower unit pricing.
The actual value of both mechanisms depends entirely on the request pattern, not simply on the model being used.
Layer 3: Total Cost per Task
A practical approximation is:
task_cost = (in_tok * p_in+ cache_hit_tok * p_cache+ out_tok * p_out) * (1 + retry_rate)
Here, retry_rate includes repeated calls caused by timeouts, failed format validation, and manual rework. For agent-based applications, the result should also be multiplied by the average number of interaction turns:
agent_task_cost = task_cost * avg_turns
Illustrative figures only—not data for any specific product—show the scale of the effect. If one generation of a model produces approximately 20% more output tokens than another, and the output price is three times the input price, the difference in cost per task can exceed 30%. By contrast, increasing the cache hit rate from 20% to 60% may often be enough to offset that increase.
3. How to Use Capability Scores Correctly
Aggregated intelligence scores from third-party benchmarks, which combine results across multiple subjects and tasks into a single figure, are useful for coarse-grained classification. They can help determine whether a model belongs to the first tier, second tier, or a tier that is usable only with limitations.
They are not well suited to fine-grained ranking among models in the same tier for three reasons:
- An aggregate score hides differences in capability distribution. A model may lead in coding while lagging in long-context comprehension.
- Benchmark tasks may not match the distribution of real business workloads, creating systematic bias.
- Higher scores often come with longer outputs and more reasoning steps, which are directly related to cost.
A more reliable engineering approach is to build a small evaluation set that closely reflects the target workload. In many cases, 100 to 300 examples are sufficient. For each candidate model, record both quality metrics and token consumption, then plot the quality-cost curve. The preferred configuration is often near the curve’s point of diminishing returns.
4. Output Token Growth: The Hidden Cost Multiplier
Longer outputs usually result from three factors:
- Explicit reasoning: The model generates a lengthy intermediate derivation before presenting its conclusion.
- Stylistic redundancy: Without length constraints, responses may become unnecessarily elaborate.
- Unconstrained structured output: Without a strict schema, JSON responses may include explanatory text before or after the JSON, causing parsing failures and retries.
The corresponding solution is to define a clear output contract:
# Use schema constraints and an output limit to reduce unnecessary generationresp = client.chat(model="model-id",messages=msgs,response_format={"type": "json_schema", "schema": task_schema},max_output_tokens=1200,)
At the application layer, teams should also distinguish between tasks that require extended reasoning and tasks that only need a short conclusion. Avoid applying identical parameters to every workload.
5. Practical Cost-Reduction Checklist
- Keep stable prefixes stable: Place system prompts, tool definitions, and fixed knowledge blocks at the beginning of the request and keep them byte-for-byte identical. Avoid inserting timestamps or random IDs into the prefix to maximize cache hits.
- Trim the context: Use retrieval instead of injecting entire documents. Summarize long conversation histories and retain only the sections relevant to the current subtask.
- Route by model tier: Send simple requests, such as intent classification and format conversion, to smaller models. Reserve larger models for complex reasoning.
- Use batch processing and asynchronous execution: Run offline workloads, such as log analysis and bulk labeling, through asynchronous capacity.
- Measure and observe usage: Add unified instrumentation at the gateway layer. Aggregate input tokens, output tokens, and cache-hit tokens by business dimension to build cost dashboards and alerts.
- Control failure costs: Set timeouts, maximum interaction turns, and budget circuit breakers to prevent agents from consuming excessive resources in loops.
A minimal routing example:
def route(task):if task.complexity == "simple":return small_model_cfg # Low-cost tierif task.requires_long_context:return long_ctx_cfgreturn flagship_cfg # High-capability tier
6. Deployment Models and Open Weights
When model weights are available in an open form, organizations gain another option: deploying inference services on container platforms or private computing infrastructure. This changes the marginal cost from usage-based token billing to fixed computing and operations costs.
This approach can be cost-effective when traffic is stable and sufficiently large. However, it also introduces additional engineering responsibilities, including inference-framework tuning, batch scheduling, autoscaling, monitoring, and alerting. Organizations must also evaluate data-compliance requirements and the pace of model updates.
For many teams, a hybrid architecture is the practical choice: run core workloads through self-hosted or dedicated deployments, while sending long-tail and burst traffic to public APIs.
7. Conclusion
“Stable prices and much higher benchmark scores” is a marketing-friendly message, but it is not a complete engineering assessment. The variables that truly determine the budget are:
- Token consumption per task
- Cache and batch-discount hit rates
- Retry frequency and the number of interaction turns
A recommended evaluation process is:
- Build a business-specific evaluation set.
- Collect quality metrics and token usage together.
- Calculate cost per task.
- Select a configuration near the turning point of the quality-cost curve.
- Continue calibrating the model with production observability data after launch.
The next stage of competition will not be defined only by the highest capability ceiling. It will also depend on which model can deliver a lower cost per task at the same level of intelligence.
