How to Evaluate Per-Task LLM Costs When API Pricing Stays the Same
When an LLM is upgraded, API token prices may not change — but the cost of delivering a completed task can shift significantly. This article explains how to convert token pricing into real task-level bills, interpret output growth and cache discounts, design fair model comparisons, measure cost per qualified task, and control costs in long-running agentic workflows before rolling out an upgrade.
1. After a Model Upgrade, Recalculate Delivery Cost — Not the Price List
When a large language model is upgraded, teams typically look at two things first: how much the overall capability score improved, and whether the API’s input and output prices changed. These are useful for initial screening, but they are not enough to judge whether the upgrade is worthwhile. Unit pricing answers “how much does one million tokens cost,” while what the business actually cares about is “how much does it cost to deliver one usable result.” Getting from the former to the latter requires accounting for the number of requests, the input and output volume per request, and whether failures require retries or human takeover.
For example, in a code generation scenario, a model might produce longer explanations for the same change, inflating the bill without improving test pass rates. Conversely, if longer output includes complete edge-case handling, allowing a task that previously needed multiple revision rounds to pass on the first attempt, then the first call becomes more expensive but the overall task may actually become cheaper. To judge whether an upgrade pays off, compare the average cost per qualified result under the same acceptance criteria.
2. Converting Token Prices into a Task Bill
For APIs billed by token, with separate pricing for regular input and cached input, you can estimate the cost of a single call as follows:
Cost per call = (uncached input tokens × regular input price + cached input tokens × cached input price + billable output tokens × output price) ÷ 1,000,000
This assumes prices are quoted per million tokens, and regular and cached input are not double-billed. When tallying usage, rely on actual usage records rather than estimating billable tokens from the text length displayed in the interface. For a single task, sum up the first request, subsequent revisions, and retries. If the process also involves retrieval, tool execution, or human review — and those steps have attributable costs — record them separately. Otherwise, money saved on the model bill may simply have moved elsewhere in the pipeline.
Output growth does not mean the bill grows at the same rate
Consider a purely illustrative example: a task’s model cost is 1 cost unit, with input accounting for 0.4 and output for 0.6. If, after an upgrade, unit prices, input volume, and call count all stay the same while output volume grows by 20%, the new cost is 0.4 + 0.6 × 1.2 = 1.12 — a 12% increase in total spend, not 20%.
This example also shows why you should examine the cost structure before optimizing. When output costs dominate, trimming irrelevant explanations, requiring only necessary fields in responses, or requesting minimal diffs is usually worth testing before compressing small amounts of input. If the main expense comes from repeatedly carrying long documents across multiple rounds, then even halving each response may not meaningfully reduce the total bill. In that case, first investigate why the historical context keeps growing and which materials only need to be loaded at specific stages.
Cache discounts only apply to input that actually hits the cache
Suppose cached input is priced 80% lower than regular input, but only a quarter of input tokens actually hit the cache. Compared with billing all input at the regular price, input costs fall by only about 20% — and that is not the reduction for the whole task, since output costs and other expenses remain unchanged. When evaluating cache benefits, focus on the proportion of input tokens that hit the cache, not merely “how many requests had a cache hit.”
For APIs that support prefix caching, you can place stable task specifications and fixed reference material at the beginning, and user input and real-time data at the end, following the API’s applicable rules, to reduce prefix misses caused by unrelated changes. But cache optimization cannot change what information a task requires: if you keep outdated specifications to maintain a stable prefix, or fail to separate contexts for tasks with different data permissions, the input cost savings may be far outweighed by rework and governance costs.
3. Similar Overall Scores Do Not Mean Similar Business Performance
An overall score condenses multiple capability dimensions into a single number, which is useful for narrowing down the candidate list. Its limitation is that different models may achieve similar total scores through different strengths, and the question types and weightings in public benchmarks may not match your actual business distribution. A model that excels at standalone short coding problems is not necessarily good at locating issues in an existing codebase, following project constraints, and keeping changes within the necessary scope.
Enterprise evaluations should sample from real requirements and categorize tasks by acceptance method. For example, coding tasks can cover new features, bug fixes, and test supplementation separately. For bug fixes, check not only whether the generated code runs, but also whether the original problem is resolved, whether existing tests pass, and whether unrelated changes were introduced. For long-running agents, focus on whether the deliverable is complete, whether key states are correct, and whether the process can resume from a verified checkpoint after an interruption. Acceptance criteria should be defined before the run, to avoid adjusting standards after seeing the results.
When comparing, first run all candidates on the same data, permissions, tool scope, and budget constraints to answer “what happens if we swap directly.” If a candidate depends on a different prompt structure or task decomposition, then run a separate tuned comparison to answer “what happens when each is deployed the way it suits best.” These two experiments answer different questions; do not mix one side’s tuned results with the other side’s default results and attribute the entire gap to model capability.
4. Use Cost per Qualified Delivery to Spot Rework Behind Cheap Calls
The most practical primary metric can be defined as:
Average cost per qualified task = total cost of all tasks during evaluation ÷ number of tasks that passed acceptance
The numerator must include the cost consumed by failures, timeouts, and retries — not just the final successful request. Consider an illustrative example: processing the same 100 tasks, Plan A spends 60 cost units in total and passes 60, averaging 1 unit per qualified task; Plan B spends 72 units and passes 90, averaging 0.8 units per qualified task. By total request spend, B costs more; by qualified output, B is cheaper. If failed tasks require human fallback, the gap may shift further, so takeover costs should be brought into the same accounting.
Beyond the average, also examine high-cost tasks. An overall cost reduction does not mean budget risk has disappeared: a small number of tasks may consume large amounts of resources due to repeated tool calls, ever-growing context, or multiple revisions. Track first-pass rate, average retry count, human takeover rate, and the 95th percentile of task cost. The percentile indicates the level that about 95% of task costs do not exceed, helping you assess spending beyond the average; if you also need to control extreme outliers, inspect the trajectories of the highest-cost tasks separately rather than treating the percentile as a cap.
5. For Long Tasks, Control the Loop First, Then Optimize Prompts
The cost of a long-running task is usually not determined by any single response, but accumulates across planning, execution, checking, and revision. If one step returns a large volume of logs and subsequent steps carry that content verbatim, the input keeps inflating; if acceptance criteria are unclear, the system may keep revising a result that already meets requirements. In such cases, switching to a cheaper model only makes each step cheaper, without solving the problem of how many extra steps are being taken.
A more effective approach is to define stage deliverables and stop conditions for the workflow. The reading stage should retain only the facts needed for subsequent decisions; the execution stage should record changes and key evidence; the verification stage should determine pass/fail against explicit rules. For anything that can be checked deterministically — structural validation, test result aggregation, budget checks — let a program handle it rather than handing entire logs to the model for repeated judgment. At the same time, set limits on maximum steps, cumulative cost, and timeouts. When a boundary is reached, save the verified progress and degrade or hand off to humans per business requirements, rather than restarting from scratch unconditionally.
These limits also need to be tuned together with quality. Compressing context may drop decisive details; an output cap set too low may truncate code or structured results; a retry limit set too strict may fail tasks that could have recovered. After each adjustment, check whether the cost savings come with a drop in acceptance pass rate, rather than only looking at whether token usage decreased.
6. Rollout Decision: Set Thresholds First, Then Decide Coverage
Before a formal switch, set a minimum quality threshold, an acceptable per-task cost, and a latency ceiling, then replay candidate solutions by task type. If offline results meet the requirements, validate with a small share of live traffic whether input lengths, cache hit rates, and retry frequencies match the offline environment. If the new solution mainly improves complex tasks, there is no need to replace all calls: for requests whose complexity can be determined in advance, you can route by task type, then verify whether the routing itself adds waiting time, duplicate calls, and maintenance overhead.
Finally, an upgrade review should be able to answer three questions: has qualified delivery increased, which tasks does the additional delivery come from, and is the extra spend acceptable. An unchanged API unit price only means the rate card has not been adjusted; a higher overall score only means better performance on a specific benchmark mix. Only by mapping bills, failure trajectories, and acceptance results to the same batch of tasks can you determine whether a model upgrade actually lowered delivery cost — or traded higher real spend for a quality improvement worth buying.
