LLM API Pricing and Cost Optimization: Why the Bill Can Rise Even When Token Prices Stay Flat
This article explains why a new-generation LLM API can cost more per task even when its published token prices are unchanged. It breaks down list price, effective cost, and cost per unit of intelligence, then presents a computable cost model showing how output token growth and cache hit rate drive real spending. You will find practical guidance on stabilizing cache prefixes, setting budget guardrails for long-running agents, and a decision framework for choosing between models with equal benchmark scores.
1. The Puzzle: Flat Unit Prices, Higher Bills
A cloud provider recently opened API access to its new-generation general-purpose LLM. The official per-token price is unchanged from the previous generation, and an independent third-party evaluation raised the model’s composite intelligence index from 53 to 60, matching another model with the same score released in the same period. On the surface, this looks like a free performance upgrade. In engineering practice, however, what determines your budget is not the unit price but the total number of tokens consumed per business task and the cache hit ratio.
Three distinct concepts need to be separated here:
- List price: the fixed price per million input/output tokens, a commercial figure.
- Effective cost: what a single task is actually charged, equal to input, output, and cached input tokens each multiplied by their respective unit prices and summed.
- Cost per unit of intelligence: effective cost divided by task success rate or evaluation score, used to compare the value of different models at the same intelligence tier.
The order of magnitude from the source can be abstracted as follows: input at roughly $1.4 per million tokens, output at roughly $4.4 per million tokens, and cached input at roughly $0.26 per million tokens, so a cache hit is equivalent to about an 81% discount. Per task, the two models in the 60-point tier cost about $0.68 and $0.84 respectively, while a model in a higher price range costs about $1.23. The signal that genuinely deserves attention is that the new version uses about 20% more output tokens to complete the same task, which directly offsets part of the benefit from unchanged unit prices.
2. Cost Model: Writing the Bill as a Computable Formula
To judge whether a price increase has actually occurred, you must abandon the unit-price view and use the following model:
cost per task =input tokens × input unit price+ output tokens × output unit price+ cached hit tokens × cache unit price+ cache miss tokens × input unit price
Because the output unit price is typically more than three times the input unit price, output token inflation has the most pronounced amplifying effect on the bill. If output volume rises 20%, then in coding tasks where output already accounts for a large share, the overall cost increase approaches or even exceeds 20%. When evaluating a new model, it is advisable to fix a set of regression tasks and record three metrics—input tokens, output tokens, and cache hit rate—then compare across versions.
An illustrative evaluation record structure:
{"task_id": "refactor_042","model_generation": "N","input_tokens": 18200,"cached_input_tokens": 15400,"output_tokens": 4100,"success": true,"latency_ms": 9800}
3. Cache Pricing: The Most Underrated Lever
The cached input unit price is only about one-fifth of the regular input unit price. In scenarios with highly repetitive prefixes—multi-turn conversations, codebase Q&A, long-document review—the cache hit rate almost determines the cost ceiling. Three practices can be applied directly:
- Stable prefix: place the system prompt, tool definitions, examples, and project conventions at the very front of the request without dynamic concatenation, and avoid letting volatile content such as timestamps or random IDs pollute the prefix.
- Segmented caching: strictly separate the invariant knowledge blocks from the user input that changes each turn, so the reusable portion is as long as possible.
- Hit-rate monitoring: bring the cache hit rate into monitoring and alerting as a first-class metric; an abnormal drop usually means the prefix was rewritten unintentionally.
SYSTEM_PROMPT = "<Stable project conventions and tool definitions; no timestamps>"def build_request(user_msg: str, history: list[dict]):# Keep the prefix byte-for-byte stable so it hits the cachemessages = [{"role": "system", "content": SYSTEM_PROMPT}]messages.extend(history)messages.append({"role": "user", "content": user_msg})return messages
4. Scenario Fit: Engineering Returns from Capability Gains
The new generation focuses on strengthening three capabilities: coding and code comprehension, defensive cybersecurity analysis, and long-horizon agent tasks. These are precisely the scenarios with the most uncertain token consumption, and they best demonstrate the value of intelligence gains diluting unit cost:
- Coding and refactoring: a correct patch on the first attempt reduces trial-and-error rounds. Although each round produces longer output, the drop in total rounds often brings total cost back down.
- Defensive security analysis: stronger static summarization of logs and code narrows the scope of manual screening, which optimizes risk cost rather than token cost.
- Long-horizon agents: more stable task planning means fewer wasted tool calls and rollbacks. Set a maximum step count and a budget cap for agents to prevent cost from spiraling.
Budget guardrail example:max_steps = 12max_total_tokens = 120000if step_budget_exceeded or token_budget_exceeded:fall back to human confirmation or emit an intermediate conclusion
5. Selection Method: A Decision Framework When Scores Tie but Prices Differ
When two models have the same intelligence score, the decision should return to four engineering metrics: effective cost per task, output token inflation rate, cache friendliness, and retry rate on failure. Evaluate in this order:
- Build a regression set from 20 to 50 real business tasks covering short Q&A, long-form generation, and code modification.
- Record the input, cached, and output tokens and success status for each call, then compute the average cost per task.
- Compute cost per successful task, counting retry overhead as a cost item outside the denominator.
- Watch the output inflation rate; if output growth in the new version significantly outpaces the improvement in success rate, actual spending rises.
- Apply tiered routing on cost-sensitive paths: send simple requests to a lightweight configuration and complex requests to a high-intelligence configuration.
6. Conclusion
Unchanged unit prices do not mean unchanged cost. Real cost is determined jointly by output length, cache hit rate, and retry count. Once intelligence scores enter the same tier, the competition shifts from “who is smarter” to “who is cheaper at equal intelligence.” The practical response for developers is to model cost, stabilize the cache prefix, move budget guardrails upstream, and continuously measure cost per successful task on your own regression set. If you need to host this evaluation data and call logs, generic object storage, logging, and monitoring and alerting capabilities can close the observability loop, keeping spending controlled, predictable, and comparable through each capability upgrade cycle.
