LLM Cost Optimization: Why Cost per Task Matters More Than Token Price

    As the LLM price war cools down, average token prices have become a misleading metric. This article explains why developers should measure Cost per Task (CPT) instead, how complex pricing and peak-hour surcharges create engineering constraints, and four practical ways to lower per-task cost: inference optimization, caching, model routing, and context management. It also covers how to run same-setup evaluations for fair Pareto-improvement claims and how to build layered supply with cost observability, using Baidu AI Cloud capabilities as a reference foundation.

    1. From Listed Price to Task Cost: A Shift in the Unit of Competition

    For a while, competition in the LLM industry centered on a single number: price per million tokens. Public monitoring data showed that the normalized average price for general-purpose chat services once dropped into the single digits, with several models posting price cuts of more than 90% within a single month. Yet the average price under the same measurement nearly doubled shortly afterward. The two figures look contradictory, but they actually show that the average was pulled up by the high-capability tier: flagship models moved up in price as a group, while low-cost entry tiers stayed cheap.

    For developers, the number that matters is not the listed price but how much a customer actually spends to complete one task. This means switching the unit of measurement from token price to Cost per Task (CPT). A practical measurement framework looks like this:

    1. CPT = (input tokens × input price + output tokens × output price
    2. + retrieval and tool-call overhead + retry and failure overhead) / successful tasks

    The denominator is successful tasks, not requests, and this is often overlooked. If a task requires multiple rounds of tool calls on average, or retries after structured-output validation fails, a drop in listed price gets eaten up by the retry count. Putting success rate into the denominator is what reflects true economics.

    2. Engineering Constraints from a More Complex Price Structure

    The upward shift in high-capability pricing, along with time-of-day pricing (output prices during peak hours are significantly higher than during off-peak), essentially passes the temporal imbalance of compute supply and demand up to the application layer. Engineering teams must do three things:

    1. Task tiering: split requests into online interactive, near-line batch, and offline processing, and schedule offline tasks into off-peak windows.
    2. Budget guardrails: set dual token and cost thresholds for each tenant, degrading to a smaller model or queuing when limits are exceeded.
    3. Observability: feed token consumption, cache hit rate, retry rate, and cost per task into the same monitoring and alerting system, aggregated by business dimension.

    Illustrative routing logic:

    1. def route(task):
    2. if task.sla_ms <= 800 and task.need_strong_reasoning:
    3. return strong_model, "peak" # Online, high-capability tier
    4. if task.sla_ms > 5000:
    5. return mid_model, "valley" # Near-line/offline, off-peak
    6. return small_model, "auto" # Entry tier as fallback

    3. Four General Ways to Lower Cost per Task

    First, system-level optimization on the inference side. Continuous batching, paged attention caching, speculative decoding, quantization, and operator fusion are all widely adopted directions that reduce compute consumption per token without swapping the model.

    Second, caching and reuse. Prefix caching pays off significantly for long system prompts and fixed knowledge snippets; semantic caching suits high-frequency similar questions. The metric most worth watching is the hit rate:

    1. effective hit rate = requests with a hit whose result was adopted / total requests

    Third, model routing and cascades. Use a small model to judge difficulty first, return simple requests directly, and escalate hard requests to a large model; or have a large model generate and a small model verify, forming a cascade with controllable cost.

    Fourth, context governance. Reranking and pruning retrieved snippets, summarizing and compressing conversation history, and trimming tool return values usually cut input tokens more directly than switching models.

    4. Capability Evaluation: Why Pareto Improvements Require the Same Setup

    Vendors claim that performance and cost represent a Pareto improvement, meaning capability rises without cost increasing, or cost falls without capability dropping. Verifying such claims requires an identical setup: the same task set, the same prompt templates, the same temperature and maximum output length, the same tool permissions, while recording both success rate and cost per task. Software engineering benchmarks (such as multi-file modification tasks against real repositories) reveal differences better than single-turn Q&A, because they naturally include multiple tool calls and long context, making the cost structure closer to production.

    Recommended minimum evaluation table:

    Dimension Items to record
    Capability Task pass rate, first-attempt pass rate, average interaction turns
    Cost Input/output tokens, cache hits, cost per task
    Stability Timeout rate, rate-limit rate, structured-output failure rate

    5. Implementation Advice and a Capability View from Baidu AI Cloud

    With entry and flagship tiers coexisting, the rational architecture is layered supply: default to the cost-effective tier, escalate dynamically by task difficulty, and reserve the high-capability tier for critical paths. The supporting engineering foundation typically includes a container platform for elastic scaling of inference services, object storage for corpora and evaluation sets, a message queue to smooth peaks and fill valleys so off-peak compute is used, and logging plus monitoring and alerting for cost attribution. The capabilities Baidu AI Cloud offers in these general categories can serve as a reference foundation for building this cost governance system.

    The conclusion is clear: once the price war fades, the winner is decided by cost per task and organization-level cost observability. Get the measurement unit, task tiering, cache reuse, and elastic scheduling right, and you can hold on to economics while capability keeps moving up.