How to Cut LLM API Costs When Prices Stay Flat
As newer LLM APIs keep the same per-token pricing as the previous generation, bills can still rise because output volume, request counts, and agent steps grow. This guide explains how to measure cost per completed task instead of per million tokens, and how to reduce spending through stable prompt prefixes and cache hits, tighter output contracts, model routing, step budgets, context compression, and cost observability.
1. Why the Bill Changes When Unit Prices Do Not
A pricing pattern worth watching has emerged in the LLM market: a new generation of models scores noticeably higher on composite capability benchmarks, while the official API prices for input, output, and cached input stay at the previous generation’s level. On the surface this looks like pure upside, but in real deployments the bill does not necessarily go down, and it can go up.
The reason lies in the structure of the billing model. Mainstream LLM API pricing can be abstracted as:
Cost per request = input tokens × input price+ output tokens × output price- discount from cache hitsCost per task = Σ(cost of all requests in the task) + cost of retries and failed requests
Unit price is only a coefficient in the formula. What actually drives the bill is the number of tokens and the number of requests. Capability gains often come with longer reasoning, more complete tool-call chains, and more verbose output, so token consumption scales up at the same time. The observation in the source material illustrates this: a newer model consumed roughly 20% more output tokens than the previous generation on the same task, which is how “no price increase” and “higher actual spend” can both be true.
So the right unit for evaluating whether a model is cost-effective is not price per million tokens, but cost per completed effective task. This is also why task-level cost metrics are now widely adopted in industry evaluations.
2. Putting Capability and Cost in the Same Frame
Public industry evaluations typically score models with a composite intelligence index, and similar scores mean a similar capability tier. When two models both sit in the 60-point tier but cost about $0.68 and $0.84 per task respectively, the gap is close to 20%. Compared with a closed-source flagship at a similar score but about $1.23 per task, the gap exceeds 40%.
The engineering takeaway is that at the same capability tier, cost differences come mainly from three places.
- Output strategy. Whether the model tends to produce long reasoning before the conclusion directly determines output token volume.
- Context management. Whether the full history is repeatedly carried in determines input token volume.
- Cache friendliness. Whether a stable prefix can be served from cache determines the effective discount on the input side.
For developers, model selection should move from “look at the score” to “look at the cost-per-task curve”: run a real business sample set, measure task success rate, average token consumption, and end-to-end latency, then convert those into cost per task before comparing anything.
3. Cache Hits: The Most Underrated Discount
Cached input is typically priced at only 20% to 30% of the regular input price, equivalent to a 20% to 30% discount. Capturing it depends on whether the request prefix stays stable. A few engineering rules help:
- Stabilize the prefix: put the system prompt, tool definitions, and a few examples at the very front, and avoid frequent changes.
- Push variables to the end: move timestamps, user IDs, random values, and other volatile content to the tail of the prompt.
- Batch requests: issue the multiple turns of one session close together to increase prefix reuse.
- Make hits observable: log cached token counts and treat them as a core metric on the cost dashboard.
An illustrative layout:
[Stable prefix: system role + tool schema + output spec] ← cacheable[Semi-stable section: retrieved domain knowledge][Volatile section: current user input, timestamp, session ID]
4. Controlling Output Length: The Biggest Lever
Since output prices are generally several times higher than input prices, output tokens are the main amplifier of the bill. Practical measures include:
- Define an output contract: specify fields, item counts, and length limits so the model does not improvise.
- Require structured responses: ask for JSON or another structured format to cut pleasantries and explanatory filler.
{"answer": "Conclusion first, no more than 80 words","evidence": ["point 1", "point 2"],"confidence": 0.0}
- Generate in stages: produce an outline first, confirm it, then expand, avoiding a full rewrite.
- Route to smaller models: send classification, extraction, and rewriting to smaller models, and reserve the flagship model for complex reasoning.
5. Long-Running Agent Tasks: Cost Grows Linearly with Steps
Agent tasks turn a single request into a multi-step loop, so cost is roughly “steps × tokens per step.” If per-step output grows by 20%, total cost rises by 20% as well, and failed retries add more on top. Controls include:
- Step budget: set a maximum iteration count and timeout threshold, and degrade or hand off to a human once the budget is exceeded.
- Context compression: summarize and archive historical tool results, keeping only conclusions and key fields.
- Trim tool returns: limit the number of items and the field scope returned by retrieval and query tools.
- Idempotency and result caching: reuse results for repeated queries instead of consuming input tokens again.
- Classify failures: separate retryable from non-retryable errors, and only send the former into the retry path.
6. Where the Capability Upgrade Lands: Coding, Defensive Security, and Automation
Capability gains in the new generation usually concentrate in three scenarios, which happen to be the cost-sensitive ones.
- Coding and code comprehension: these need long context and multiple rounds of correction, so pair them with retrieval augmentation and inject only relevant file snippets rather than the whole repository.
- Defensive cybersecurity: log anomaly classification, vulnerability description summarization, and alert noise reduction are defensive analysis within compliance scope, and a human review step should be kept.
- Long-running automation: suited to orchestrated workflows, and it needs monitoring, alerting, and logging services, with cost aggregated per task.
On the cloud, these can be carried by general-purpose building blocks: a container platform hosts the inference gateway, object storage holds sample sets and artifacts, a message queue smooths task spikes, and logging plus monitoring and alerting provide cost observability. If you use the relevant general-purpose product categories from Baidu AI Cloud, the same advice applies: make cost per task, not price per token, the core dashboard metric.
7. Conclusion
Flat unit prices with a higher capability tier signal that the model market has entered a cost-competition phase. What really determines an enterprise bill is token efficiency and the quality of task orchestration. Bringing cache hit rate, output length, and agent step count into day-to-day governance is what pushes cost per task lower at the same capability tier.
