How to Calculate the True Cost Per Task for Large Language Models

    A practical guide to reproducible cost-per-task accounting for LLMs. Learn why benchmark parity and lower token prices can still hide higher real spending, how reasoning token efficiency changes model selection, and how to build a task-level cost model for budgeting, latency testing, and capacity planning. Includes pseudocode, a cost table template, and an action checklist.

    Last night, a Chinese LLM team released a new-generation model API, with pricing kept the same as the previous generation. A third-party evaluation leaderboard shows that this generation’s composite intelligence index improved by 7 points, tying a flagship model with several times the total parameter count and a larger activated parameter count per call. On the surface, this looks like “a small model catching up to a large one,” but the conclusion reverses once you do the math: both its input and output token prices are significantly lower, yet the actual cost per task is only about 20% cheaper. The reason is not price but reasoning token efficiency—it consumes about 41K tokens per task on average, versus 25K for its competitor.

    This article does not restate the pros and cons of any particular product. Instead, it abstracts the problem into a general engineering proposition: how to build a reproducible method for cost-per-task accounting, and then use it for model selection, budget control, and capacity planning.

    1. Put “matching the intelligence index” back in context

    A leaderboard score is a highly compressed scalar. It weights and aggregates multiple capabilities—knowledge, reasoning, code, instruction following—into a single number. Two models with the same score only means there is no difference under that particular set of weights; it does not mean there is no difference on your business distribution. So the first step is not to compare scores, but to build your own evaluation set: sample from real call logs, label by intent category, retain long-tail and adversarial samples, and run batches with fixed prompts, fixed decoding parameters, and a fixed retry policy. Only when the evaluation criteria are fixed does the subsequent cost comparison become meaningful.

    At the same time, distinguish the characteristics brought by an iteration pattern of “unchanged base model, enhanced post-training.” Improving performance on the same base model through preference optimization, rejection sampling, reinforcement learning, and similar methods usually does not change interface-level capabilities such as context length, structured output support, or function-calling protocols. What engineering should focus on is whether this upgrade changed the default reasoning mode, whether it changed the stopping condition, and whether it changed the return structure of tool calls. Any one of these changes will directly rewrite your token bill.

    2. Why parameter count cannot be linearly extrapolated into capability

    Total parameter count determines the upper bound of model capacity, while activated parameter count determines the compute per forward pass; together they affect memory usage, batch throughput, and latency distribution. Sparse architectures make “large capacity, small activation” possible, resulting in cases where total parameters differ by several times but actual compute is similar. But sparsity is not free: routing causes uneven expert load, the key-value cache grows linearly with sequence length under long contexts, and large variance in request length within a batch produces noticeable bubbles and queuing.

    So capacity planning should look not at parameter count but at three measurable quantities: prefill time per request, decode time per token, and cache hit ratio. The illustrative stress-test and accounting code below only demonstrates the method and does not point to any specific platform interface:

    1. # Pseudocode: cost-per-task accounting
    2. def task_cost(usage, price_in, price_out, cache_hit_ratio=0.0):
    3. in_tok = usage["prompt_tokens"]
    4. out_tok = usage["completion_tokens"] # includes reasoning tokens and visible output
    5. cached = in_tok * cache_hit_ratio
    6. billable_in = (in_tok - cached) * price_in + cached * price_in * 0.25
    7. return billable_in / 1e6 + out_tok * price_out / 1e6
    8. # Key: the denominator is "successfully completed tasks", not the number of calls
    9. def cost_per_task(total_cost, success_tasks):
    10. return total_cost / max(success_tasks, 1)

    3. The real dividing line: reasoning token efficiency

    Dividing the unit price by the table below does not yield a conclusion; you must introduce the variable “tokens per task.” Let the input unit price be p_in, the output unit price be p_out, input tokens per task be I, and output tokens per task be O; then the cost per task is (I·p_in + O·p_out). When the output unit price is more than three times the input unit price, small changes in O are amplified. One model averaging 41K and another averaging 25K is a 1.64x gap, enough to eat up a several-fold advantage in unit price.

    Reasoning token efficiency can be defined as the number of tokens consumed per unit of effective output. It is affected both by the model’s “reasoning length preference” and by the caller’s “prompt and decoding configuration.” Actionable improvements include:

    1. Make the reasoning budget explicit. Set different maximum reasoning tokens and timeouts for different intents; turn off long reasoning for simple classification, extraction, and rewriting tasks.
    2. Slim down the context. Rerank and deduplicate retrieval results first, changing “stuff into the context” to “stuff in the most relevant evidence,” and use rolling summaries of conversation history rather than concatenating everything.
    3. Put structured constraints up front. Define output with a schema to reduce rework and second calls caused by the model improvising.
    4. Account for the cost of failure. Include the hidden costs of retries, timeouts, and fallbacks to larger models in the denominator; many “cheap” solutions are not cheap on long-tail tasks.

    4. Converting unit price into budget: a reproducible accounting template

    It is recommended that teams maintain a “task-level cost table” with fields including at least: intent label, average input tokens, average output tokens, cache hit ratio, first-attempt success rate, average number of retries, and end-to-end latency percentiles. Regress this table against the real bill every week to detect cost drift caused by prompt changes and model upgrades.

    1. Intent I(avg) O(avg) Cache hit First-pass success Cost per task
    2. Short Q&A 1.8K 0.6K 0.35 0.98 Low
    3. Long summarization 6.0K 1.2K 0.10 0.93 Medium
    4. Code generation 12.0K 3.5K 0.05 0.81 High

    5. Cost reduction at the architecture level: routing, caching, and async

    A cost curve from relying on a single model for everything is inevitably ugly. A viable pattern is tiered routing: first use a small model or rules for intent recognition and feasibility judgment, return directly for high confidence, and escalate to a stronger model for low confidence; build a semantic cache for repeated requests and return on a hit; send batch tasks that tolerate latency through an asynchronous queue, trading throughput for unit price; and put preprocessing steps such as long-document parsing and vectorization on general cloud services—for example, object storage, message queues, container platforms, log services, and monitoring and alerting—using elastic scaling to absorb peaks rather than keeping peak capacity resident.

    6. Conclusion and action checklist

    “Matching” is a capability narrative; “only 20% cheaper per task” is the engineering reality. When selecting a model, fix the order as: build your own evaluation set → measure tokens per task → account for cost per task → stress-test latency and throughput → then implement tiered routing. Three things you can do immediately: set a reasoning budget cap for each intent category; include first-attempt success rate and retry count in the cost denominator; and build a cost dashboard that regresses weekly. Only by doing these three things can you judge whether a model upgrade actually reduces cost or merely shifts the cost into token consumption.