LLM API Pricing vs. Per-Task Cost Reduction

    List prices per million tokens often mislead LLM budgets because real tasks inflate tokens through prompts, retrieval, tools, retries, and long outputs. This article shows how to decompose bills, stack usage cuts with price cuts, and govern cost by task success rather than sticker rates.

    Enterprises that adopt large language models often first notice input and output prices per million tokens. Those unit prices are easy to read and easy to misuse. A real task is rarely a single clean completion. System prompts, retrieved passages, tool results, multi-turn history, failed retries, and longer generations all multiply tokens. Even if a standard API’s input and output prices both fall by about 20%, per-task cost may fall more—or barely move. The difference is in how you call the model, not in the price list itself.

    Break the bill into a computable structure

    Typical text APIs bill by token and price input and output separately. Output is usually much more expensive because generation uses more compute. Direct cost of one call is:

    cost ≈ input_tokens × input_price + output_tokens × output_price

    If one capability tier has higher input and still higher output prices, and another is cheaper on both, routing “expensive model for critical steps, cheap model for drafts and classification” is often more stable than using one tier end to end. A percentage drop in unit price is not the same as a percentage drop in task cost. Let a call have input I and output O, old prices Pi and Po, new prices Pi′ and Po′. The saving ratio is:

    1 − (I·Pi′ + O·Po′) / (I·Pi + O·Po)

    Task cost falls in lockstep with unit prices only when input and output drop by the same ratio and I and O stay constant. If teams then lengthen context, write fuller answers, or retry more because “it is cheaper,” usage on the denominator can erase or exceed the price gain.

    Conversely, if you shorten useless context, cap output, and cut failed retries while prices fall, usage decline and price decline stack, and per-task cost can drop more than unit prices. When news says “per-task cost fell more than list prices,” engineering usually means this stack—not a hidden discount off the menu.

    Where usage gets amplified

    Expand one business request and common multipliers include:

    1. Fixed prompts. Role, format, safety bounds, and a few examples are billed as input on every call. On short tasks they dominate, so a unit-price cut saves little in absolute terms.
    2. Retrieval stuffing. Pasting multiple documents into context grows input linearly with length. Low-relevance chunks are still billed.
    3. Multi-turn history. Without summarization, prior turns are billed again each round; cost roughly accumulates with turns.
    4. Tool round-trips. External results written back into the model add input and can trigger longer output.
    5. Retries and sampling. Timeouts, invalid format, and multi-sample “pick the best” turn one task into several billed calls.
    6. Unbounded output. Without a length cap, models tend to explain process and repeat arguments—and output is usually the higher-priced side.

    Cost governance therefore targets all tokens needed to complete the business goal, not the sticker price of a single completion.

    Illustrative numbers for the stacking effect

    The figures below show quantity relationships only; they are not any vendor’s real prices or benchmarks.

    Assume old prices of 10 currency units per million input tokens and 50 per million output tokens; after a cut, 8 and 40 (20% on both sides). A task uses 8,000 input tokens and 1,000 output tokens.

    Before: 0.008×10 + 0.001×50 = 0.13
    After, same usage: 0.008×8 + 0.001×40 = 0.104, exactly 20% down.

    If retrieval context is cut from 8,000 to 5,000 and output is capped at 600 tokens:

    0.005×8 + 0.0006×40 = 0.064

    Versus the original 0.13, that is about a 50% drop—clearly more than the 20% list-price cut. If after the cut you instead dump 20,000 tokens of material and allow 2,000 output tokens:

    0.02×8 + 0.002×40 = 0.24

    The bill rises. That is why a “cheaper API” can still worsen the monthly invoice: usage elasticity can exceed price elasticity.

    A cheaper tier, e.g. input 2 and output 10 (again illustrative only), on the same 5,000-in / 600-out job costs about 0.016. It fits classification, extraction, drafts, and routing; it is a poor sole owner of high-risk decisions without checks. Choose tiers by cost of error, not token price alone.

    Apply cost levers in order

    Do not start by swapping models. A more stable order is: measure, cut waste, then change tiers and repricing.

    Measure. Tag every business request with task type, model tier, input tokens, output tokens, retry count, cache hit, end-to-end latency, and whether the business succeeded. Look at P50 and P95 cost, not only the mean; tails often come from abnormal retries and huge context. Logs and metrics can live in ordinary logging and monitoring; what matters is stable fields so you can aggregate by app, tenant, and prompt version.

    Cut input. Shorten the fixed prompt; keep only the fewest examples that actually change format. Filter retrieval by relevance, truncate snippets, and cap both the number of chunks and each chunk’s length. Replace full multi-turn replay with a rolling summary that itself has a length cap. Do field assembly and enum checks in code, not in the model.

    Cut output. Set a generation max in API parameters and ask the prompt for structured fields only. Prefer short JSON or key-value over long prose. If explanations are needed, put them in an on-demand second call instead of generating them every time.

    Cut call count. Cache results for identical inputs; the cache key must include model tier, prompt version, and key parameters so stale answers are not reused. On format failure, prefer rule-based repair over resampling the whole generation. Cap tool-call steps to prevent loops.

    Then change tiers. On a small labeled set, compare high and low tiers on accuracy, refusal rate, and per-call cost. Move down only when business loss is smaller than the money saved. Keep the high tier for ambiguous, high-compliance, or long-horizon reasoning steps. Routing rules should be rollback-ready so one release does not dump all traffic onto the cheap tier.

    How to land this on the platform

    Applications own prompts and context; the platform owns quotas, budgets, and audit. Set per-app daily budgets and burst multipliers; near the threshold, degrade to shorter context or a lower tier instead of failing hard. Object storage can hold prompt versions and eval samples; a message queue can run batch jobs asynchronously. Batch work often amortizes fixed overhead better than online one-by-one calls, but whether batch is cheaper depends on the contract—do not assume it.

    Do not evaluate only “stronger.” Record both correctness and tokens spent per sample. If accuracy rises while output length doubles, state how much quality cost. A release gate can be: on a fixed sample set, task success is at least baseline, and P95 per-task cost is no higher than an agreed fraction of baseline. Price changes, prompt revisions, and model swaps then share one acceptance language.

    Keep estimation vendor-agnostic:

    1. cost = input_tokens * price_in + output_tokens * price_out
    2. task_cost = sum(cost for each attempt) # includes retries; excludes unused cache hits
    3. saving = 1 - task_cost_new / task_cost_old

    Put the price table in config, not business code, so finance changes are config-only. When comparing bills across periods, report a “price effect” (new prices × old usage) and a “usage effect” (old prices × new usage) so prompt bloat is not misread as a price hike.

    Common mistakes

    Treating a price announcement as an annual budget cut and ignoring usage elasticity. Cutting only input while output costs several times more. Removing format constraints to save tokens, then paying more in parse failures and retries. Sending all traffic to a cheap model whose savings do not cover human correction. Caching without prompt-version keys and returning stale answers. A hidden waste: evals on short questions and production on long documents—pre-launch cost samples must replay production-length (redacted) traffic.

    If you already run inference plus logs, monitoring, and object storage on Baidu AI Cloud or another cloud, the method is the same: unify token and task IDs, bill by task not by API call, and constrain quality with evals. Do not pin savings on one generation’s list prices or extrapolate from headlines. Unit price is an input; all tokens required for a successful task are the output. Govern both, and per-task cost can fall more than list prices—and the drop stays explainable and reversible.