LLM API Pricing Rebuilt: A Practical Guide to Cost Optimization
As LLM API prices shift rapidly, this article breaks vendor price lists into a computable cost model, explains why output tokens dominate spending, and shows how to cut costs through structured output, prompt caching, context governance, and tiered model routing. It also provides a selection and governance checklist for keeping architecture stable while pricing keeps changing.
1. The Shift: API Price Lists Are Being Rewritten
LLM API prices are changing more frequently than before. Across vendors, products in the same generation commonly adopt a tiered pricing strategy: the flagship tier keeps its existing price but emphasizes that each token carries more useful work, while balanced and lightweight tiers enter the market at significantly lower prices. Some vendors have also introduced cache-hit discounts, sharply reducing the marginal cost of repeated context.
It is worth noting that “extremely low” is a relative term. Compared with some high-end models, the prices of new entrants are indeed an order of magnitude lower; across the broader market, however, they can still be higher than several lightweight models. Price comparisons must therefore use a consistent basis, or they can easily lead to wrong conclusions.
2. Turning a Price List into a Computable Model
Vendor price lists may look different, but once abstracted they are mostly made up of four dimensions:
- Input token price and output token price are separate, with output typically 3–6 times more expensive;
- Cached input tokens receive a discount, commonly 5%–20% of the original price;
- Model tiers are formed by capability/cost ratio into flagship, balanced, and lightweight;
- Limited-time discount prices are used for market penetration during the launch of a new version.
Expressed uniformly:
cost = (in_tokens * p_in + cached_tokens * p_in * r + out_tokens * p_out) / 1e6# p_in/p_out: price per million tokens; r: cache discount factor (0~1)
For example, a public tier might be around 5/30 (USD per million input/output tokens), a balanced tier around 2.5/15, a lightweight tier around 1/6 or 2/6, and another tier around 1.25/4.25 with a cache-hit rate of about 0.15. Only by plugging these into the same formula can you align them with your own business’s token distribution.
3. Why Output Tokens Are the Main Cost Battleground
In most real bills, the output side accounts for more than the input side, because output is priced higher and long-form generation pushes up both input (accumulated history) and output at the same time. The recommended optimization order is: first compress output length and structured redundancy, then govern input context, and only then consider switching to a cheaper model. Reversing this order often yields limited results.
Structured output is a typical waste point. If you ask the model to return a full JSON object but downstream only consumes three fields, you can switch to field trimming plus streaming parsing:
# Keep only the necessary fields to reduce output tokensschema_hint = "Output JSON only: {title, score, tags}"resp = call_model(prompt, system=schema_hint, stream=True)for chunk in resp:buf += chunkif buf.endswith("}"):break # Stop early to avoid redundant continuation
4. Caching and Context Governance
The essence of a cache-hit discount is turning a stable prefix into a sunk cost. In engineering terms, put invariant content such as system prompts, tool definitions, and long documents at the front and keep it byte-for-byte stable, and put volatile content such as timestamps, random IDs, and user nicknames at the end. Any change to the prefix invalidates the entire cached segment.
[Stable prefix: system instructions + tool schema + knowledge snippets] <- cacheable[Semi-stable: conversation summary][Volatile: current question + timestamp] <- not cached
Supporting measures include deduplicating and reranking retrieved snippets for retrieval-augmented scenarios while controlling the number of recalled items; using rolling summaries rather than concatenating the full history for multi-turn conversations; and splitting long documents first and loading them on demand.
5. Tiered Routing: Making Cost Reduction an Architectural Capability
Relying on a single model for everything produces the worst cost structure. A practical approach is to build a routing layer that splits traffic by task difficulty while keeping a quality regression gate:
def route(task):if task.kind in {"classify", "extract", "format"}:return "light" # lightweight tierif task.risk == "high" or task.need_reasoning:return "flagship" # flagship tierreturn "balanced" # balanced tier
Routing needs to be backed by an offline evaluation set, using accuracy/compliance rates to constrain the downgrade ratio and avoid “lower cost means lower quality.” At the same time, connect downgrade events, token consumption, and cache hit rates to logging services and monitoring alerts to form an observable closed loop.
6. Selection and Governance Checklist
- Establish a unified pricing basis and convert all candidate models into “cost per thousand business requests”;
- Run load tests with real traffic replay rather than relying on vendor-stated parameters;
- Set budget thresholds and rate-limiting circuit breakers to prevent abnormal inputs from inflating the bill;
- For high-frequency short requests, prioritize the lightweight tier plus caching;
- Periodically review the risk of prices reverting after limited-time discounts expire;
- Keep a multi-provider abstraction layer to avoid tight coupling with a single interface.
7. Conclusion
What the price war really changes is not a single line of numbers, but the status of cost engineering: token budgets, caching strategies, tiered routing, and observability are becoming design constraints as important as model capability. Only by treating cost as a programmable first-class citizen can you keep your architecture stable while the price list keeps changing.
