Choosing a Large Language Model: From List Prices to Cost per Task
List prices for large language models only tell part of the cost story. This guide breaks down the four variables that determine the real cost of a single task—input tokens, output tokens, cache hit rate, and call count—and shows how to use reasoning effort levels, context windows, and internal evaluations to compare models by cost per successful task rather than by per-million-token pricing. Includes a ready-to-use Python cost estimator and a practical selection workflow.
1. List Price Is Only the Starting Point
Large language models are typically billed by token, and the quoted price usually consists of three parts: an input price, an output price, and a cached-token price. Many teams compare only the per-million-token price when choosing a model, then find that the actual bill doesn’t match their expectations after launch.
The reason is simple: unit price only determines the cost of each token. What determines total cost is how many tokens a task consumes, which types of tokens it consumes, and whether the task requires multiple calls.
Model selection should therefore start from “how much does it cost to complete one task,” not from “how much does a million tokens cost.”
2. The Four Variables Behind Cost per Task
1. Input token count. Input includes the system prompt, conversation history, retrieved documents, and tool results. A long-running agent re-sends its prior context to the model at every step, so input volume accumulates with each step.
2. Output token count. Output includes the final answer, and in some services also the reasoning process, which is counted as billable output. The higher the reasoning effort, the more output is typically generated, and the cost rises accordingly.
3. Cache hit rate. When multiple requests share the same prefix, cached reads can significantly reduce input costs. The benefit depends on two factors: whether the prefix is stable, and whether the cache’s time-to-live covers the interval between consecutive requests.
4. Number of calls. A single task may involve planning, execution, verification, and retries. As the retry rate goes up, total cost increases roughly proportionally—which means the retry strategy itself is part of cost design.
3. Reasoning Effort: The Dial Between Cost and Quality
Most services offer reasoning effort levels from low to high. At higher levels, the model invests more computation before answering. Success rates on complex math, code fixing, and multi-constraint planning tasks usually improve, but latency and cost increase as well.
The sensible approach is to tier tasks by difficulty:
- Simple classification, information extraction, and text rewriting: use low effort, prioritizing latency and cost.
- Standard Q&A and document summarization: use medium effort.
- Multi-step reasoning, code modification, and long-horizon planning: use high effort, with a budget cap.
- Reserve the highest effort level for a few critical steps, such as final result verification.
Defaults can differ across services and model versions, so specify the effort level explicitly in your code rather than relying on the default.
4. Context Window: Big Enough Beats Biggest
A large context window does not mean you should cram all your material into a single request, for three reasons:
- Input cost grows linearly with length.
- In long contexts, the model’s ability to locate key information may degrade.
- Time to first token increases with input length.
In practice, combine retrieval-augmented generation, chunked summarization, and state compression to keep each step’s input within what the task actually requires. For agents, periodically compressing past steps into a structured state is usually cheaper—and more reliable—than retaining the full conversation history.
5. Evaluate Capabilities with Your Own Tasks
Public benchmarks offer a rough reference, but their task distribution rarely matches real business workloads. It’s better to build an internal evaluation set:
- Sample 100 to 300 cases from real requests, covering both common scenarios and edge cases.
- Define automatically checkable pass criteria for each case, such as unit tests, field matching, or rule-based validation.
- Run the evaluation for each candidate model at each reasoning effort level, recording success rate, average output tokens, latency percentiles, and cost per task.
- Use “cost per successful task”—total cost divided by the number of passing tasks—as the core metric.
A combination with a low unit price but a markedly lower success rate may actually cost more per successful task. This metric captures that difference directly.
6. Example: Estimating Cost per Task
The following function estimates the cost of a single task. Price parameters should follow the provider’s current official pricing; the code hard-codes no specific prices.
def estimate_task_cost(input_tokens: int,cached_tokens: int,output_tokens: int,price_input: float, # Price per million input tokensprice_cache: float, # Price per million cached-read tokensprice_output: float, # Price per million output tokenscalls: int = 1,) -> float:"""Estimate the total cost of one task, in the same unit as the prices."""uncached = max(input_tokens - cached_tokens, 0)per_call = (uncached * price_input+ cached_tokens * price_cache+ output_tokens * price_output) / 1_000_000return per_call * callsdef cost_per_success(total_cost: float, success_count: int) -> float:"""Compute the cost per successful task."""if success_count == 0:return float("inf")return total_cost / success_count
To use it, pass in the measured average token counts for each candidate combination, then compare results with cost_per_success. The resulting numbers are far closer to your real bill than a comparison of list prices.
7. A Decision Workflow for Model Selection
- Define a quality threshold, such as a minimum task pass rate.
- Screen candidate combinations (model plus reasoning effort level) that meet the threshold on your internal evaluation set.
- Compute each combination’s cost per successful task and its high-percentile latency.
- Make the final call based on data compliance requirements, deployment model, and service reliability.
- Wrap model APIs behind a unified invocation layer to preserve the ability to switch providers and reduce future migration costs.
8. Operational Tips
- Set budget and rate limits to prevent runaway costs from agent loops.
- Log input, output, and cache-hit data for every call, and attribute costs by task type so you can identify high-consumption stages.
- Prices, quotas, and model versions all change. Note the verification date on any figures in your documentation and review them periodically.
- Have a fallback plan for critical paths—for example, switching to a low-cost backup model when the primary model times out or errors—and log the reason for each switch.
