Choosing LLMs: Why Per-Task Cost Matters More Than Unit Price
When evaluating Large Language Models (LLMs), relying solely on token unit prices can lead to inaccurate cost estimates. This article explains why per-task cost is a more reliable metric for budget planning and architecture design. We explore the impact of parameter scale, the hidden costs of reasoning tokens, and how to calculate and normalize per-task costs against model quality, providing actionable best practices for optimizing your LLM API usage.
1. Background: A Low Unit Price Doesn’t Mean a Cheap Task
LLM APIs are typically billed based on the number of input and output tokens, priced per million tokens. When comparing two models, it is easy to compare unit prices directly and conclude that “the model with the lower unit price saves money.” However, this comparison considers only one variable and ignores the actual number of tokens a model consumes to complete a given task.
What businesses truly care about is the cost of completing an objective—such as generating a report, fixing a bug, or processing a support ticket. The per-task cost is determined by three components: the unit price, the average number of input tokens per task, and the average number of output tokens per task. Output tokens usually include those generated by the model’s internal reasoning, a part that is often overlooked. Missing any of these three will cause your estimates to deviate from reality.
2. Parameter Scale: Total vs. Active Parameters
Model size is usually described by two numbers. The total parameter count determines the storage and VRAM requirements for the model weights, serving as the primary deployment barrier. The active parameter count refers to the parameters actually involved in a single forward pass, which determines the computation required to generate each token and is closely related to inference speed and unit computation costs.
In models using a Mixture of Experts (MoE) architecture, the difference between these two numbers is particularly stark. These models contain numerous expert subnetworks but only route each token to a select few experts during processing. Consequently, a model with a massive total parameter count might require significantly less computation per inference than a dense model with the same total parameter size.
This means that judging cost or capability based solely on total parameters is unreliable. When evaluating, you should simultaneously check the active parameter count, the deployment method, and the actual unit pricing published by the service provider. Parameter scale describes the model’s resource structure; it cannot directly substitute for cost data.
3. Reasoning Tokens: The Overlooked Cost Variable
Reasoning-oriented models generate internal thought processes before providing their final answer, and these tokens are typically billed as output. As a result, the number of billed output tokens can far exceed the text length of the final response. A model might score higher on benchmarks partly because it uses longer reasoning chains, which directly drives up call costs.
When evaluating, track the following metrics separately:
- Average input tokens: The total length of prompts, historical context, and retrieved results.
- Average output tokens: All outputs, including the thinking process.
- Output token distribution: Median and 90th percentile. A few long-tail tasks can skew the average; percentiles better reflect the real load.
- Truncation and retry rates: Setting the output limit too small will cause tasks to be truncated, and failed retries will result in duplicate billing.
Token efficiency is an independent dimension for evaluating reasoning models. When two models offer similar quality, the one with fewer average output tokens is usually better suited for high-frequency call scenarios.
4. Converting Unit Price to Per-Task Cost
The formula for calculating per-task cost is as follows:
Per-Task Cost = (Average Input Tokens × Input Unit Price + Average Output Tokens × Output Unit Price) ÷ 1,000,000
Let’s use a set of hypothetical illustrative values to demonstrate the calculation. These values do not correspond to any real product.
Example 1: Model A has an input price of $0.5 per million tokens and an output price of $2.0 per million tokens, with an average input of 3,000 tokens and an average output of 40,000 tokens.
Per-Task Cost = (3,000 × 0.5 + 40,000 × 2.0) ÷ 1,000,000 = $0.0815
Example 2: Model B has an input price of $1.0 per million tokens and an output price of $4.0 per million tokens, with an average input of 3,000 tokens and an average output of 10,000 tokens.
Per-Task Cost = (3,000 × 1.0 + 10,000 × 4.0) ÷ 1,000,000 = $0.043
Model B’s unit price is double that of Model A, but its per-task cost is only about 53% of Model A’s. The difference comes from the output length. A unit price comparison ignores this, whereas per-task cost factors it in.
You can use the following function for batch estimation:
def estimate_task_cost(input_tokens: float,output_tokens: float,input_price_per_m: float,output_price_per_m: float) -> float:"""Estimate the API cost for a single task in USD.Prices are in USD per million tokens."""return (input_tokens * input_price_per_m+ output_tokens * output_price_per_m) / 1_000_000
When calculating, use token statistics from real business samples rather than example data from marketing pages. If the service provider offers cached pricing for repeated context prefixes, you must separately account for cache hit and cache miss tokens according to their actual billing rules.
5. Normalizing Cost with Quality Metrics
Comparing costs alone cannot yield a selection conclusion; quality must be compared simultaneously. A feasible approach is to calculate the cost per unit of quality, which is the per-task cost divided by the quality score. When the scores of two models are close, this metric directly reflects value for money. If the score gap is significant, you must factor in the business’s tolerance for quality.
When using benchmark results, also keep the following in mind:
- Benchmark vs. Business Alignment: The question distribution of general leaderboards may not cover your specific business scenarios.
- Inference Parameters: Settings like temperature and maximum output length significantly affect the output token count.
- Statistical Consistency: Verify whether the token counts reported include the thinking process.
- Time Factor: Provider prices, model versions, and behaviors can all change; conclusions should be reviewed periodically.
6. Practical Implementation Advice
- Build a business evaluation set: Extract 100 to 500 samples from real requests, covering simple, medium, and complex tasks, and annotate the expected results.
- Log token details: Record input, output, and reasoning tokens per request to analyze distributions rather than just looking at averages.
- Set output limits: Set the maximum output token count based on the 90th percentile of output length, and design fallback or retry strategies for truncated tasks to avoid duplicate billing.
- Tiered routing: Assign simple tasks to lower-cost models, escalating only complex tasks to more capable models. Routing rules can start with simple task type judgments:
def route_model(task_type: str) -> str:# Example rule: Select model based on task complexity.# Specific thresholds need to be determined by evaluation results.simple_tasks = {"classification", "extraction", "summary"}if task_type in simple_tasks:return "low_cost_model"return "high_capability_model"
- Compress prompts: Remove redundant instructions and trim context irrelevant to the task to reduce input tokens per call.
- Re-evaluate periodically: Incorporate per-task cost and quality metrics into your monitoring dashboard, and re-assess when prices or model versions change.
7. Conclusion
Unit price is the starting point for selection, but per-task cost is the basis for decision-making. Placing parameter scale, reasoning token efficiency, quality scores, and real business samples in a single table for comparison yields conclusions that can be directly applied to budgeting and architecture design.
