Large Language Model Inference Cost: Token Efficiency and Per-Task Economics

    Token pricing alone does not determine the real cost of using a large language model. This article presents a practical framework for evaluating inference costs through three dimensions—capability, token efficiency, and per-task cost—and explains how post-training, context management, routing, caching, observability, and regression testing affect the cost-performance curve.

    1. The Problem Begins with a “Tie”

    A notable pattern has recently emerged in the industry: a new model matches the score of a flagship model that has an order of magnitude more parameters on public benchmarks, while its API token prices are only a fraction of the flagship model’s prices. At first glance, the conclusion seems obvious: the new model offers a major improvement in cost-effectiveness. However, once the full calculation is made, the actual gap is often much smaller than the pricing gap suggests.

    The reason is straightforward: token price is only one factor in cost, not the cost itself. The real cost depends on how many tokens are required to complete a business task. When token efficiency—the number of tokens consumed per task—declines, the advantage of lower pricing is systematically diluted.

    This pattern is becoming more common rather than remaining limited to isolated cases. As a result, inference cost evaluation needs to move beyond intuition and adopt a repeatable engineering methodology.

    2. Three Perspectives for Evaluating Large Language Models

    1. Model Size and Active Parameters

    For sparse architectures, such as mixture-of-experts models, two numbers must be distinguished:

    • Total parameter count: determines memory requirements, deployment hardware thresholds, and static costs.
    • Active parameter count: determines the amount of computation performed in a single forward pass and is strongly related to inference latency and throughput.

    A model with approximately 700 billion total parameters and 40 billion active parameters is not equivalent in per-inference compute to a model with more than one trillion total parameters and 100 billion active parameters.

    Therefore, active parameter count is a more useful indicator of actual compute consumption for capacity planning. For private deployment, however, total parameter count determines whether the model can be deployed at all.

    2. Overall Capability Scores

    Public composite benchmarks, which normalize and weight results across multiple disciplines and tasks, are useful for preliminary screening. They can help determine whether a model should enter the candidate set. However, they have two inherent limitations:

    • They do not reflect your business workload distribution: benchmark tasks often differ substantially from real-world traffic.
    • They do not reflect cost: two models with similar scores may consume more than 50% different numbers of tokens.

    The practical conclusion is that benchmarks should be used to select candidates, not to make the final decision.

    3. Inference Token Consumption

    This is the most frequently overlooked dimension, yet it can have the greatest impact on the bill. Inference tokens generally consist of two parts:

    • Reasoning tokens: the model’s internal reasoning process, which many platforms charge as output tokens.
    • Output tokens: the final content returned to the user.

    A model may gain significant benchmark points because post-training encourages it to “think more thoroughly,” while also increasing the token consumption of each task. Capability gains and consumption increases occurring at the same time are a typical side effect of post-training optimization.

    3. Calculating the Full Cost: A Per-Task Cost Model

    The basic formula is:

    1. cost_per_task = (in_tokens * price_in + out_tokens * price_out) / 1e6

    Here, in_tokens includes the system prompt, conversation history, and retrieved context. out_tokens includes both reasoning tokens and the final output.

    The following pseudocode illustrates the evaluation method. The numbers are hypothetical and are provided only to demonstrate the calculation:

    1. function evaluate(candidates, workload):
    2. for m in candidates:
    3. total = 0
    4. for task in workload:
    5. r = m.run(task) # r includes usage statistics
    6. total += (r.in_tokens * m.price_in
    7. + r.out_tokens * m.price_out) / 1_000_000
    8. report(m.name,
    9. index = m.benchmark_score, # capability
    10. tok = avg(r.out_tokens), # efficiency
    11. cost = total / len(workload))

    Consider a simple example. Candidate A charges 1.4 for input and 4.4 for output per million tokens, with an average output of 41,000 tokens per task. Candidate B charges 3.0 for input and 15.0 for output per million tokens, with an average output of 25,000 tokens per task.

    After conversion, Candidate A’s per-task cost is approximately 80% of Candidate B’s cost—not less than one-third, as the unit prices might suggest.

    The key lesson is clear: a twofold decline in token efficiency can offset nearly a twofold price advantage.

    4. How Post-Training Changes the Capability-Cost Curve

    A model can achieve substantial benchmark improvements through post-training alone, including instruction tuning, preference alignment, and reinforcement of reasoning chains, without changing its underlying base model. Pricing often remains unchanged during this type of upgrade.

    This can provide excellent value when measured by capability per dollar. However, it may not provide the same value when measured by capability per token.

    From an engineering perspective, every model version upgrade should be treated as a change in cost structure, not simply as a free performance improvement. The upgrade process should include the following mandatory regression checks:

    1. Capability regression: scores on the organization’s internal evaluation set must not decline.
    2. Efficiency regression: average tokens consumed per task must remain below the defined threshold.
    3. Cost regression: changes in per-task cost must remain within budget.
    4. Latency regression: P95 latency must satisfy the SLA.

    If any requirement is not met, the previous version should be retained or tiered routing should be enabled.

    5. Engineering Methods for Improving Token Efficiency

    • Context management: rerank and trim retrieved passages, and summarize conversation history to avoid repeatedly sending irrelevant content.
    • Prompt simplification: remove redundant instructions and repeated examples to reduce input tokens and prevent instruction conflicts that can trigger excessive reasoning.
    • Reasoning budget controls: explicitly limit reasoning depth for simple tasks and reserve deep reasoning for difficult tasks.
    • Prefix caching: place stable system prompts and knowledge blocks at the beginning of the context so they can be reused, reducing repeated computation and cost.
    • Tiered model routing: use lightweight models for frequent, simple requests and route difficult problems to larger models.
    • Batching and asynchronous processing: use batch processing channels for offline workloads to reduce the unit cost.
    • Output constraints: combine structured output with length limits to prevent uncontrolled expansion.

    6. Observability: Optimization Requires Measurement

    Cost accounting must be based on data. At a minimum, collect the following metrics:

    • Request volume
    • Input, output, and reasoning token distributions
    • Cache hit rate
    • Failure and retry rate
    • Per-task cost
    • P95 latency

    In practice, a complete workflow can combine general cloud capabilities. A logging service can store structured invocation logs, monitoring and alerting can enforce thresholds for cost and successful-completion rates, object storage can archive evaluation datasets and invocation samples, and a message queue can smooth traffic spikes and support batch-processing pipelines.

    When building such a workflow on Baidu AI Cloud, the same general capability categories can be combined. There is no need to depend on any proprietary interface.

    7. Common Misconceptions

    1. Inferring total cost directly from token prices.
    2. Looking only at benchmark scores without evaluating the organization’s own workload.
    3. Ignoring the billing treatment of reasoning tokens.
    4. Ignoring hidden consumption caused by retries and failures.
    5. Upgrading a model without running cost and efficiency regressions.
    6. Allowing context to grow indefinitely, resulting in persistently high input-token consumption.

    8. Conclusion

    The correct approach to model selection is to evaluate three dimensions at the same time: whether capability is sufficient, whether token efficiency is acceptable, and whether per-task cost fits the budget.

    Parameter count determines deployment feasibility. Benchmarks determine whether a model qualifies for consideration. Token efficiency, however, is what has the greatest direct impact on the bill.

    By using per-task cost as a unified metric, enforcing regression gates for model upgrades, and establishing end-to-end observability, teams can maintain genuine cost-effectiveness as models evolve rapidly—rather than being misled by token prices alone.