LLM Cost per Task: Beyond Token Unit Price

    Token unit price is only one component of LLM task cost. This article explains how output and reasoning tokens, token efficiency, parameter scale, task success rate, and engineering practices affect cost per task, with a calculation example and a practical evaluation workflow.

    1. A Low Unit Price Does Not Mean a Low Cost per Task

    LLM APIs are usually billed per million tokens, with separate pricing for input and output; output unit prices are generally higher than input unit prices. The cost of a single task consists of two parts:

    Cost per task = input tokens × input unit price + output tokens × output unit price

    There are two variables in this formula that are easy to overlook. First, output token count is not equal to the length of the final answer. For models with a reasoning process, tokens generated during reasoning are also billed at the output unit price and are usually not fully shown to the user. Second, different models consume very different numbers of tokens to complete the same task. Comparing only unit prices is equivalent to looking at only part of the formula.

    2. Reasoning Token Efficiency Determines Cost

    Reasoning token efficiency refers to the number of tokens a model consumes to complete a given task. A highly efficient model can obtain results of equivalent quality with less reasoning and fewer output tokens, while a less efficient model tends to repeatedly reason or produce redundant content.

    When judging efficiency, measure the following metrics on the same task set:

    • Average output token count, as well as percentiles such as P50 and P90, to avoid a small number of unusually long samples hiding the true distribution;
    • The proportion of tokens used for reasoning versus the final answer, provided the API can distinguish between the two;
    • Timeout rate and truncation rate. When output is truncated, the cost has already been incurred, but no usable result is produced.

    Averages can hide the long tail. Suppose most tasks require only a few hundred tokens, but about 5% of tasks enter long reasoning; these tasks may account for most of the total cost. Therefore, both averages and percentiles need to be observed.

    3. The Relationship Between Parameter Scale and Cost

    A model’s publicly disclosed parameter scale is often used as a proxy for capability or cost, but the two do not correspond directly.

    • Total parameter count determines the GPU or memory footprint of model weights, affecting the hardware configuration required for deployment and the provider’s infrastructure cost.
    • In a mixture-of-experts architecture, the number of activated parameters determines the main forward-computation cost per token and is related to per-token inference cost.
    • Training includes pretraining, supervised fine-tuning, and reinforcement learning. Together, they determine how much capability a model can release at the same scale.

    The same base model may show clearly different benchmark scores after different post-training. However, post-training may also teach the model to use longer reasoning chains, thereby increasing token consumption. Capability improvements and cost increases may occur at the same time and need to be quantified separately; it is not enough to look at only one direction.

    4. From Benchmark Scores to Effective Cost

    Composite benchmark scores are suitable for coarse screening but cannot be used directly for cost comparison. Two models with the same score may differ severalfold in cost per task. A more practical metric is “cost per correct result,” which can be approximated with the following formula:

    Effective cost ≈ cost per task ÷ task success rate

    This formula assumes that failed tasks need to be retried and that the retry cost is the same as the first execution. If failed tasks can be abandoned directly or handled manually, calculate separately according to the actual workflow.

    5. A Calculation Example

    The following numbers are fictional illustrative values, used only to explain the calculation method. They do not represent the price or performance of any real product.

    Assume Model A has an input unit price of USD 1 per million tokens and an output unit price of USD 4 per million tokens, with an average of 5,000 input tokens and 40,000 output tokens per task. Model B has an input unit price of USD 3 per million tokens and an output unit price of USD 15 per million tokens, with an average of 5,000 input tokens and 25,000 output tokens per task.

    The cost per task for Model A is 5000×1/10⁶ + 40000×4/10⁶ = USD 0.165. For Model B, it is 5000×3/10⁶ + 25000×15/10⁶ = USD 0.390.

    Model B’s output unit price is 3.75 times that of Model A, but its cost per task is only about 2.4 times that of Model A. Model B’s lower output token count offsets part of the unit price gap. If the two models have different task success rates, the effective cost formula should also be used for comparison.

    The corresponding calculation code is below:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class PriceConfig:
    4. input_per_million: float # Input price, USD per million tokens
    5. output_per_million: float # Output price (including reasoning tokens), USD per million tokens
    6. def cost_per_task(input_tokens: int, output_tokens: int, price: PriceConfig) -> float:
    7. """Calculate the cost of a single task in USD."""
    8. return (
    9. input_tokens * price.input_per_million
    10. + output_tokens * price.output_per_million
    11. ) / 1_000_000
    12. def cost_per_success(task_cost: float, success_rate: float) -> float:
    13. """Calculate cost per correct result assuming failed tasks are retried."""
    14. if not 0 < success_rate <= 1:
    15. raise ValueError("success_rate must be in the range (0, 1]")
    16. return task_cost / success_rate
    17. if __name__ == "__main__":
    18. price_a = PriceConfig(input_per_million=1.0, output_per_million=4.0)
    19. price_b = PriceConfig(input_per_million=3.0, output_per_million=15.0)
    20. cost_a = cost_per_task(5000, 40000, price_a) # 0.165
    21. cost_b = cost_per_task(5000, 25000, price_b) # 0.390
    22. print(f"A: {cost_a:.3f} B: {cost_b:.3f} Ratio: {cost_b / cost_a:.2f}")

    6. Practical Evaluation Workflow

    It is recommended to carry out evaluation in the following steps to avoid making decisions based only on public data:

    1. Build a representative task set. Sample from real business scenarios, cover easy, medium, and difficult tasks, and ensure the number is sufficient to reflect the long-tail distribution.
    2. Record token usage by type. Record input, reasoning, and output tokens separately, and save the latency and result status of each task.
    3. Set a quality gate first. Define acceptable accuracy or human scoring criteria; models that do not meet the standard should not enter cost comparison.
    4. Calculate the cost distribution. Output the mean, median, and P90 of cost per task, and calculate effective cost.
    5. Add latency and stability metrics. Include time to first token, overall latency, rate limiting, and timeouts. If the lowest-cost option cannot meet business latency requirements, it is also unusable.
    6. Retest periodically. Model versions, billing rules, and prompts all change, so evaluation results should have a limited shelf life.

    7. Engineering Approaches to Reduce Cost per Task

    After evaluation, teams can usually optimize cost in the following directions:

    • Tiered routing: route simple tasks to cheaper, faster models and escalate complex tasks to more capable models. Routing rules can be based on task type or a front-end classifier.
    • Control the reasoning budget: for APIs that support reasoning limits, configure reasonable limits by task type to prevent invalid long reasoning.
    • Streamline prompts: remove repeated system instructions and irrelevant context to reduce input tokens. For fixed prefixes, caching mechanisms can be used to reduce repeated billing.
    • Constrain output format: require the model to return only structured results, such as specified JSON fields, to reduce redundant explanations.
    • Batch processing: for tasks that do not require real-time responses, use the platform’s batch channel, which usually offers a lower unit price.
    • Cache results: reuse historical results for identical or highly similar requests, which is suitable for scenarios such as question answering and classification.

    8. Considerations

    • The source, version, and evaluation set of benchmark scores must be clearly labeled. Scores from different evaluation sets cannot be compared directly.
    • Public prices may change; cost estimates should be based on actual bills and measured data.
    • The counting definition of output tokens must be consistent. Some APIs include reasoning tokens in output, while others list them separately; confirm the billing rules before making direct comparisons.
    • Cost is only one dimension of model selection. Data security, compliance requirements, service stability, and replaceability also need to be considered.

    In short, unit price determines the price of each token, while cost per task is jointly determined by token quantity, task success rate, and engineering strategy. Only when these variables are placed in the same evaluation framework can model-selection conclusions stand up to scrutiny.