Low-Cost LLM Inference Pricing and Engineering Practices Guide
This guide explains why large language model inference costs keep falling and how engineering teams can control them in practice. It breaks down the four token categories used in LLM billing, presents a per-request cost formula, and shows why prefix cache hit rate is the single largest cost lever. It then covers output token governance, tiered model routing, throughput and latency optimization, and a deployment checklist for building a token-level cost model, cost dashboards, and budget alerts.
1. Why the Cost Per Call Keeps Falling
A wave of very low-priced LLM services has recently appeared. Their published pricing sits at roughly this level: about $0.10 per million input tokens, about $0.004 per million cached input tokens, and about $0.50 per million output tokens. Converted to RMB, that is about 0.67 yuan for input, 0.03 yuan for cached input, and 3.36 yuan for output. Compared with the common price range of mainstream small models, the overall cost is roughly one third, while the vendor claims comparable quality.
The price drop is not just marketing. It is the result of several engineering capabilities stacking up:
- Lighter model architecture: fewer parameters, shallower layers, and narrower hidden dimensions directly reduce the floating-point operations in a single forward pass.
- Inference precision and quantization: low-bit weight and activation quantization significantly cut memory footprint and bandwidth pressure, which raises per-GPU concurrency.
- Batching and scheduling: techniques such as continuous batching and paged attention cache management push GPU utilization higher and amortize fixed costs.
- Cache reuse: reusing the computed result of a shared prefix avoids duplicate computation. This is the fundamental reason cached input can be priced as low as $0.004 per million tokens.
For developers, the real gain is this: the cost structure shifts from “roughly estimated per call” to “precisely modeled per token,” which gives capacity planning and budget control engineering-grade precision for the first time.
2. Understanding the Billing Model: Four Token Types and the Cost Formula
A low unit price does not mean a low bill. To control cost, start by breaking the billing items apart. General LLM billing usually includes four categories:
- Input tokens: all context carried in the request.
- Cached input tokens: the portion that hits the prefix cache, typically priced at a fraction of a few dozen times less than regular input.
- Output tokens: generated content, typically priced several times higher than input.
- Storage and operations charges: if you use supporting capabilities such as vector retrieval, log retention, or object storage, these are billed separately.
This gives the cost formula for a single request:
Cost = Lin * Pin + Lcache * Pcache + Lout * Pout
Here Lin is the input length that misses the cache, Lcache is the input length that hits the cache, Lout is the output length, and P* is the corresponding unit price.
A concrete example: the system prompt and tool definitions total 4,000 tokens and all hit the cache, the user question is 300 tokens and misses, and the output is 500 tokens. At the prices above, the per-request cost is on the order of 0.00012 + 0.00025 = 0.00037 USD, a few hundredths of a cent. If the cache misses entirely, input cost grows by roughly 25x. That ratio shows cache hit rate is the most important cost lever in this approach, with far more impact than which service you pick.
3. Cache Hit Rate: The First Lever for Low Cost
The general principle of prefix caching is to retain the attention key-value computation results for an identical token sequence at the start of a request, so later requests with the same prefix can reuse them directly. To capture this benefit, follow a few practical rules:
- Keep the prefix stable: put the system prompt, tool definitions, examples, and knowledge base notes at the front, and do not insert volatile content such as timestamps or random IDs.
- Put changes last: place user input and retrieved snippets at the end of the prompt so they do not pollute the prefix.
- Make it long enough: most implementations require the prefix to reach a minimum length threshold before it is written to the cache, so a short shared fragment cannot hit.
- Set a reasonable lifetime: cache entries usually have a time-to-live, so after a traffic dip and recovery you should expect a period of cold start.
A counter-example:
[Timestamp 2026-08-11T22:15] You are a customer service assistant... (followed by a stable long prompt)
With the timestamp at the very front, the entire prefix differs every time and the cache is fully defeated. The correct form moves volatile information to the end:
You are a customer service assistant... (long stable prompt and tool definitions)Current time: 2026-08-11T22:15User question: ...
4. Output Tokens Are the Bulk of the Bill
Output is priced at 5x input, and generation length is often uncontrollable, so governance on the output side has higher priority:
- Cap the maximum generation length, and set different limits per scenario; extraction tasks do not need much headroom.
- Use structured output to cut redundancy, for example requiring strict JSON to reduce pleasantries and explanatory padding.
- For long-text tasks, use segmented generation with incremental persistence to avoid large-scale rework after a single generation.
- Build a “generate-validate-retry” loop and include retry counts in the cost model instead of looking only at the ideal path.
Illustrative code (pseudocode, conveying the idea only):
def call_model(prompt, max_out=512, retries=2):for i in range(retries + 1):resp = client.chat(messages=build_messages(prompt), # stable prefix firstmax_tokens=max_out,response_format={"type": "json_object"},)if validate(resp):return respreturn fallback(resp)
5. Tiered Model Routing: Save the Expensive Model for Hard Problems
The right way to use a low-cost small model is not a wholesale replacement but to let it carry the bulk of traffic and route complex requests upward. A typical tiering looks like this:
- Tier 1: rules and cache. High-frequency repeated questions hit an answer cache directly, at zero model cost.
- Tier 2: small, low-cost models. Handle deterministic tasks such as classification, extraction, rewriting, and intent recognition, covering most requests.
- Tier 3: mid-size models. Handle multi-step reasoning and long-document summarization.
- Tier 4: high-capability models. Handle only the small number of requests judged difficult.
Routing decisions can combine lightweight signals: input length, whether the input contains code or tables, first-pass confidence, and explicit user feedback. In engineering terms, make routing thresholds configuration items and keep calibrating them with an offline evaluation set, so cost savings do not cause quality to collapse.
6. Throughput and Latency: The Other Half of Cost Optimization
Unit price is only half the bill; the other half is resource utilization. If you keep large amounts of idle compute for low latency over the long term, the real cost per token will be far above the listed price. Practices worth attention include:
- Use continuous batching to raise concurrency density so long and short requests run mixed without blocking each other.
- For offline tasks that tolerate latency (batch summarization, data cleaning), use an asynchronous queue to smooth peaks and process in concentrated batches.
- Automatically scale container instances based on monitoring and alerting metrics such as queue time, time to first token, and batch size.
- Connect logs and metrics to a unified logging service and monitoring and alerting system to form a cost observability dashboard that attributes token consumption by business line.
7. Deployment Checklist
- Have you moved the stable prefix to the front and verified the hit rate?
- Have you set differentiated maximum output lengths for each task type?
- Have you built structured output validation with a retry limit?
- Have you implemented tiered routing and answer-level caching?
- Have you built a token-level cost dashboard and budget alerts?
- Do you continuously verify the quality baseline after cost reduction with an offline evaluation set?
8. Conclusion
An inference service at as little as one third of the cost is essentially the result of pushing “compute reuse” and “resource utilization” to the extreme. For development teams, the reusable methodology is clear: first build a per-token cost model, then use prefix caching and output constraints to lower per-request cost, then use tiered routing to apply capability where it matters most, and finally use an observability system to turn cost into a sustainable engineering metric. If you need to carry a complete application pipeline, you can build an elastic architecture on general cloud capabilities such as object storage, message queues, container platforms, logging services, and monitoring and alerting, and implement the approach above on platforms such as Baidu AI Cloud to keep the per-call cost of an LLM application within a predictable range.
