Choose Large Models by Task Cost, Not List Price
A practical framework for comparing LLMs by the full cost of completing a task, including token usage, caching, long-context pricing, retries, latency, quality, and human rework. It explains how to build representative workloads, model tiered pricing, evaluate cost by usage percentiles, and route different tasks to the most suitable model.
Choose Large Models by Task Cost, Not List Price
One of the easiest mistakes in model selection is treating the first line of a pricing page as the final answer. When APIs charge by token, the same business task can consume very different numbers of input and output tokens depending on the model, prompt design, context length, and cache behavior. Costs can differ by an order of magnitude.
The metric that matters is not simply “How much does input cost?” or “How much does output cost?” It is:
How much should it cost to complete this task, how reliable is the result, and will failures and retries multiply the bill?
This article breaks down the total cost in an engineering-friendly way and provides a practical evaluation sequence. All numbers below are illustrative. They explain the calculation method and do not represent any provider’s current pricing.
Break the Bill into Its Main Components
The cost of a single API call can usually be expressed as:
Task cost ≈ input tokens × input price+ cached-read tokens × cached-read price+ cache-write fee, if charged separately+ output tokens × output price+ long-context surcharge, if triggered+ failed retries and tool round trips
The easiest items to overlook are not always the visible prices. They are the usage patterns behind those prices.
Input tokens can come from the system prompt, business context, retrieved passages, conversation history, and the current user request. Output tokens include not only the final answer, but also reasoning content, tool arguments, and intermediate drafts if the provider bills them as output.
Cached reads are often much cheaper than sending new input, but only when the prefix is stable, the cache window is still valid, and the provider actually treats the content as cached rather than as ordinary input. Some pricing models charge separately for cache writes, sometimes with different rates based on retention duration. If writing to the cache is expensive, the prefix must be read enough times to make the investment worthwhile.
Long-context rules require particular attention. Some products apply one price to the entire request. Others increase the input, cache, and output multipliers once the input exceeds a threshold. Under the second rule, going only slightly over the threshold can make the entire request more expensive.
As a result, a model with a lower unit price for short requests may not be cheaper for very long inputs. A model with uniform pricing may be more expensive for short requests but cheaper for long ones. Comparisons must use your actual length distribution rather than simply ranking models by the pricing table.
Build Samples from Tasks, Not Token Counts
Use production logs or load tests to create representative samples instead of relying on vendor demonstration prompts.
1. Short tasks
Examples include classification, extraction, single-turn rewriting, and small function completions. Inputs are often a few thousand to roughly ten thousand tokens, while output length is predictable because of format constraints.
2. Medium-sized tasks
Examples include question answering with several retrieved passages, code review, and localized changes across multiple files. Both input and output lengths can vary significantly. Cache hit rates depend heavily on whether the system prompt remains stable.
3. Long tasks
Examples include summarizing an entire repository, reviewing long documents, and multi-turn agents that repeatedly add tool results to the context. For these tasks, track whether a single request crosses the long-context threshold and whether pricing applies only to the excess tokens or to the entire request after the threshold is crossed.
For each category, record at least:
- Input tokens
- Cached-prefix tokens
- Output tokens
- Whether a higher pricing tier was triggered
- End-to-end latency
- First-pass success rate
- Average retry count
Without success-rate data, cost will be systematically underestimated. One failed attempt followed by a retry can nearly double token usage, and the retry may also carry a longer, incorrect context into the next round.
Example: Two Pricing Models for the Same Task
Assume a task has 400,000 input tokens, including a stable 100,000-token prefix eligible for cached reads. The remaining 300,000 input tokens are new, and the output contains 8,000 tokens.
The following two pricing schemes are for illustration only. They demonstrate how uniform pricing and whole-request tiering can produce different results.
Uniform pricing
- Input: 3 per million tokens
- Cached read: 0.3 per million tokens
- Output: 15 per million tokens
Cost ≈ 0.30 × 3 + 0.10 × 0.3 + 0.008 × 15= 0.90 + 0.03 + 0.12= 1.05
Tiered pricing
Under the second scheme:
- Before the long-context threshold:
- Input: 2 per million tokens
- Cached read: 0.2 per million tokens
- Output: 10 per million tokens
- Once input exceeds 272,000 tokens, the entire request uses:
- Input: 4 per million tokens
- Cached read: 0.4 per million tokens
- Output: 15 per million tokens
Because this request exceeds the threshold, the higher rates apply to the full request:
Cost ≈ 0.30 × 4 + 0.10 × 0.4 + 0.008 × 15= 1.20 + 0.04 + 0.12= 1.36
Now apply the same comparison to a short task with 20,000 input tokens, no cache, and 1,000 output tokens:
Uniform pricing:0.02 × 3 + 0.001 × 15 = 0.075Lower pre-threshold pricing:0.02 × 2 + 0.001 × 10 = 0.05
The lower-priced tier wins for short tasks, while uniform pricing wins for the long task. This is the opposite of what a simple comparison of input prices would suggest.
If the lower-priced option also charges separately for cache writes—for example, with different fees for 30-minute and 12-hour retention—the 1.36 estimate is still incomplete. Whether the cache write pays off depends on how many times the prefix is read during its effective lifetime.
If the prefix is written and read only once, the write fee may exceed the input savings. If it is read dozens of times, the cost can be spread across many calls and caching may become advantageous. A comparison table that lists only the cached-read price must state clearly that cache-write fees are excluded. Otherwise, it can unfairly favor caching for workloads with long prefixes and low repetition.
Usage Distribution Matters More Than the Average
Using the average input length in a cost formula can hide the effect of a tier boundary. Assume the threshold is T. If 90% of requests are below 0.5T and 10% are at 1.2T, the average may still be below T. However, if the long requests are charged at the higher rate for the entire request, those 10% can contribute more to the monthly bill than the other 90%.
Evaluate usage by percentile instead:
- P50 input length
- P90 input length
- P99 input length
- Percentage of requests where input exceeds
T - Percentage of total cost contributed by those requests
Three practical controls work across providers:
- Put stable system instructions, tool specifications, and rarely changing reference material in the prefix to improve cache reuse. Put user data and retrieved results in the suffix so changes do not invalidate the entire prefix.
- Split and retrieve long documents structurally, sending only relevant passages to the model. This keeps most requests below the threshold. Reserve long-context requests for tasks such as full-document review or reconciliation that genuinely require complete coverage.
- Constrain output with a schema or format, such as limiting JSON fields and explanation sections. This reduces output expansion. Retries should also have a budget: cap both the retry count and cumulative tokens for a task so an agent loop cannot keep enlarging the context indefinitely.
Quality Is Not Free, but Leaderboards Are Not Enough
After calculating cost, verify whether the task can actually be completed successfully. Public benchmarks measure average performance on fixed datasets, which may not match your support tickets, codebase, or industry documents.
A more reliable approach is to build a small golden set from real workloads. Select 50 to 200 examples from production issues and define acceptable answers or scoring criteria. Run every candidate model with the same prompt, temperature, and maximum output length. Record:
- First-pass success rate
- Percentage requiring human rework
- Human time required for that rework
Model selection should use an expected-cost calculation rather than treating “smarter” and “cheaper” as separate properties:
Expected cost =successful-path model cost+ failure rate × retry cost+ rework rate × labor cost × rework time+ concurrency and timeout losses caused by latency
Latency often becomes a direct cost through queueing and timeouts. If long-context requests are slower, the same QPS may require more concurrency capacity. Timeout retries then increase token usage and return the cost to the model bill.
For interactive workloads, a model that exceeds the required P95 latency may be unusable even if its token price is lower.
A Practical Comparison Checklist
Before discussing model selection, fill in the following details so the conversation does not remain focused on unit prices.
Billing dimensions
- Are input, output, cache reads, and cache writes billed separately?
- Are cache writes charged per operation or by retention duration?
Long-context pricing
- Is there a threshold?
- Does the higher rate apply only to tokens above the threshold or to the entire request?
- Do cache and output prices change along with the input price?
Usage structure
- What are the token percentiles for the three task categories?
- What percentage of requests triggers the higher tier?
- What is the cache hit rate?
Quality
- What are the first-pass success and rework rates on your golden set?
- Are you evaluating actual task performance rather than relying only on external leaderboard rankings?
Reliability
- How are timeouts, rate limits, and empty outputs retried?
- Is there a cost ceiling for retries?
Compliance and data handling
- Is the context allowed to leave your environment?
- How long are logs retained?
- How sensitive is the cached content?
A prefix cache effectively leaves part of the prompt on the provider’s side for a period of time. Sensitive data therefore requires a separate review.
Once these factors are measured, the common result is not to use one model across the entire application. Instead, route tasks by workload:
- Short, structured, high-QPS paths can use a lower-priced tier with stable latency.
- Tasks that must process very long materials can use a model with uniform long-context pricing, or a model whose higher tier is still cheaper than repeated retrieval.
- High-difficulty, low-volume review tasks can tolerate a higher unit price.
The routing logic itself also consumes tokens. Adding an excessively long classification prompt just to decide which model to use can consume the savings it was intended to create.
Recommended Measurement Sequence
Step 1: Sample production traffic
Extract input, output, and prefix-length percentiles from logs. Do not export only total token usage.
Step 2: Normalize the pricing calculation
Represent each candidate’s pricing rules in the same spreadsheet or calculation function. Compute the cost for every sample and then aggregate monthly cost. Do not multiply an average length by a unit price.
Step 3: Analyze threshold crossings
Identify samples that exceed the long-context threshold. Test how much quality decreases if they are truncated to remain below it. Use that comparison to decide between retrieval-based truncation and accepting the higher tier.
Step 4: Experiment with caching
Run caching as an explicit on/off experiment. For a stable prefix, compare cache hit rate, cache-write fees, and read savings over seven days. If the hit rate is not high enough, do not pay for cache writes.
Step 5: Enforce the quality floor
Use the golden set to define a minimum quality threshold. Reject any option below that threshold, even if it looks attractive on the pricing page.
A simplified implementation might look like this:
cost = in_fresh * price_in(tier)+ in_cached * price_cache_read(tier)+ cache_write_fee+ out * price_out(tier)tier = long if input_tokens > THRESHOLD and rule == "whole_request" else short
Read prices and thresholds from the contract or provider console. Do not hard-code an assumed price into application code.
After launch, publish a daily report by task type covering:
- Call volume
- Higher-tier usage
- P90 cost per task
- Retry amplification factor
When a category deviates from the estimate, adjust the prompt, retrieval strategy, or routing logic instead of immediately changing the model-selection narrative.
Conclusion
In AI applications, differences between model tiers ultimately appear in token structure.
For short requests, focus on input and output prices as well as latency. For long requests, first determine whether the higher tier applies to the entire request or only to excess tokens, then evaluate whether cache writes can be amortized through repeated reads. For every workload, include failed retries and human rework in the cost of completing the task.
The first line of a pricing table is only a starting point. Model selection becomes defensible when usage percentiles, threshold rules, reliability, and quality requirements are evaluated in the same model.
