Reducing LLM Inference Costs with Time-Based Pricing and Cache Optimization
Lower inference prices do not automatically translate into lower total operating costs. This article explains how to model cached input, uncached input, and output charges; schedule delay-tolerant workloads; improve input reuse; and control generation length without compromising quality. It also outlines the monitoring, budgeting, and security practices needed to evaluate savings by cost per successfully completed task.
1. Why Lower Prices Call for a New Request Strategy
A reduction in large language model inference prices directly lowers the bill for the same volume of requests. For developers and businesses, however, the more important question is whether their existing request strategy remains cost-effective under the new pricing structure.
LLM requests typically involve several charges rather than a single flat rate. These may include cached input, uncached input, and output. When peak and off-peak pricing also applies, the same task using the same model capabilities can incur substantially different costs depending on execution time, context organization, and output length.
Sustainable cost optimization therefore requires more than choosing a cheaper time window. It must address four questions:
- Which tasks can wait, and which require an immediate response?
- How much input can be reused consistently?
- Does output length match the business value it delivers?
- Have lower prices changed request volume, retry frequency, or human review costs?
Evaluating these factors together is what turns a lower unit price into a genuine reduction in total business cost.
2. Break Down the Bill Before Evaluating Price Changes
Three Cost Categories That Should Not Be Conflated
Cached input generally means that part of a request’s input meets the provider’s conditions for server-side cache reuse and is billed accordingly. It does not mean the entire request is free, nor does it necessarily mean that a previous answer is reused.
Uncached input is the portion of the input that does not receive a caching discount. Dynamic user questions, frequently updated business documents, and context that fails to meet caching requirements may fall into this category.
Output charges cover the content generated by the model. For long-form writing, report generation, and multi-turn analysis, output can account for most of the cost. Optimizing input alone may therefore have a limited effect on the overall bill.
Some services may include additional billing items. Always use the provider’s official billing rules rather than assuming every LLM service has the same cost structure.
An Illustrative Price Comparison
The following figures are illustrative values for billing analysis, not current prices for any service. Because the underlying material does not specify the billing unit, prices are expressed in CNY per billing unit. They should not be interpreted as prices for any fixed number of tokens.
| Billing item | Example price before adjustment | Example price after adjustment | Reduction |
|---|---|---|---|
| Cached input | 0.05 | 0.02 | 60% |
| Uncached input | 1.50 | 1.00 | Approximately 33.3% |
| Output | 4.50 | 4.00 | Approximately 11.1% |
The key point is that the reductions differ across billing categories.
Cached input receives the largest percentage reduction, but if it accounts for only a small share of the original bill, its impact on total spending remains limited. Conversely, an 11.1% reduction in output pricing can deliver substantial absolute savings for output-heavy workloads.
The largest reduction in an individual rate should not be treated as the reduction in total business cost.
3. Build a Reproducible Request Cost Model
Let:
- (I) be the total input volume for a request.
- (O) be its output volume.
- (h) be the cache-hit proportion measured by billable input volume.
- (P_h) be the cached-input unit price.
- (P_m) be the uncached-input unit price.
- (P_o) be the output unit price.
Assuming these three categories account for all charges and there are no additional fees, request cost is:
[
C = IhP_h + I(1-h)P_m + OP_o
]
Input and output volumes must use the same billing units as their respective prices. For example, character counts cannot be inserted directly into a token-based formula. The ratio between characters and tokens is not fixed across different texts.
If all three rates use the same time-based multiplier, the formula can be simplified to:
[
C_t = k_t \times C
]
Here, (k_t) is the pricing multiplier for the applicable time window. This simplification is valid only when all billing categories share that multiplier. Otherwise, calculate each category separately.
Worked Example
Assume a batch of tasks uses 10 input billing units and 2 output billing units, with an input cache-hit proportion of 80%. Using the example prices above, the cost before adjustment is:
[
10 \times 0.8 \times 0.05 +
10 \times 0.2 \times 1.50 +
2 \times 4.50 = 12.40
]
After adjustment, it is:
[
10 \times 0.8 \times 0.02 +
10 \times 0.2 \times 1.00 +
2 \times 4.00 = 10.16
]
The total reduction is approximately 18.1%, not the 60% reduction in the cached-input rate.
Now assume all peak-period rates are twice the off-peak rates. Under the adjusted prices, running the same batch during the peak period would cost 20.32.
This example shows that, under some pricing structures, execution timing can have a larger effect than a unit-price adjustment. Actual scheduling must still account for deadlines, processing capacity, and user experience—not just the bill.
4. Start Off-Peak Scheduling by Classifying Tasks
Prioritize User Experience for Real-Time Tasks
Online question answering, interactive assistance, and immediate business decisions generally cannot wait several hours just to reduce inference costs.
For these workloads, response latency and availability come first. Cost optimization should focus on removing redundant input, setting appropriate output expectations, and reducing duplicate requests.
Forcing real-time requests into cheaper time windows may cause user churn or business disruption, with losses that exceed the inference savings.
Queue Delay-Tolerant Tasks
Document archive summaries, batch content organization, historical record classification, and offline report generation are often better candidates for off-peak execution.
Tasks can be placed in a message queue with metadata such as:
- Completion deadline
- Business priority
- Estimated input and output volume
- Whether the task can be split
- Maximum retry count
- Data sensitivity level
The scheduler can then select execution times based on pricing windows, remaining budget, and processing capacity. If a task is approaching its deadline, business requirements may require it to run even when prices are higher.
Avoid Launching the Entire Backlog at Once
Submitting every queued task as soon as a cheaper window opens can trigger rate limits, queueing, and excessive retries, reducing the expected savings.
A more reliable approach is to smooth execution: limit concurrent requests, control the processing rate, and add randomized delays to retries. If failures persist, pause submissions or reduce the sending rate rather than retrying indefinitely.
Time-window calculations must use the time zone specified in the billing rules. Also verify how requests crossing pricing boundaries are charged. Whether weekends or holidays have special rules—and whether pricing depends on request start time or processing time—must be checked in the official documentation rather than inferred.
5. Optimize Caching Through Stable Reuse, Not Larger Contexts
Separate Stable and Dynamic Content
General task instructions, formatting requirements, and long-lived background information can be managed as stable content. User questions, real-time data, and temporary supporting material are dynamic content.
If a service uses prefix-based input caching, placing stable content first and dynamic content afterward generally supports prefix reuse. However, matching conditions, cache lifetime, and minimum length depend on the provider’s rules. Do not assume all services support the same mechanism.
Keeping changing timestamps, random identifiers, and unnecessary ordering changes out of stable content also helps avoid needless differences between requests.
A Cache Hit Does Not Justify Unlimited Input
Even when cached-input rates are low, additional input may still incur charges and consume context space. Irrelevant material can also interfere with the model’s understanding of the main task.
The optimization sequence should be:
- Remove unnecessary information.
- Organize reusable content.
- Evaluate the resulting caching benefit.
For long-document tasks, select passages relevant to the question instead of submitting the entire document every time. For multi-turn conversations, compress history while preserving essential information, and check that summaries do not omit critical constraints.
Measure Cache Benefits Using Actual Billing Data
Where possible, measure cache-hit rate by billable input volume rather than by the percentage of requests with any cache hit. A cache hit on a short request does not contribute the same savings as a hit on a long request.
Track differences across workloads as well. Fixed-format batch processing may offer more reusable input than highly personalized interactive tasks. Optimization should follow observed data, not assume that results from one task category apply everywhere.
6. Control Output Costs Without Sacrificing Quality
Output optimization is not about asking the model to write as little as possible. It is about aligning generated content with the task’s purpose.
For information extraction, specify the required fields, format, and treatment of missing values. For summaries, define the scope of coverage. For decision tasks, request the conclusion first, followed by the necessary supporting rationale.
Clear task definitions are usually more effective than a vague instruction to “keep it short.”
If the service supports output-length limits, set appropriate boundaries for each task type. Monitor truncation, incomplete formatting, and follow-up requests. Limits that are too restrictive can force users to ask additional questions and increase total cost.
A more useful metric is total cost per successfully completed task, including failed requests, retries, follow-up calls, and necessary human review—not just the charge for the first request.
7. Make Cost Optimization Part of Engineering Governance
Track Costs by Business Workload
Record input volume, output volume, cached-input volume, execution-time distribution, failure rate, and actual charges by business workload, environment, and task type.
Set daily or monthly budget thresholds. When costs rise unexpectedly, determine whether the cause is normal business growth or an operational issue such as expanding context, duplicate submissions, uncontrolled retries, or incorrect configuration.
Validate Strategies with a Small Pilot
Start with a subset of delay-tolerant tasks. Compare total cost, completion time, failure rate, and result quality before and after optimization.
If savings come with missed deadlines or substantially more manual correction, adjust the strategy. Cost-effectiveness must be evaluated against business acceptance criteria.
Do Not Trade Security or Reliability for Lower Prices
Delayed execution keeps data in queues or storage for longer. Apply appropriate access controls, retention limits, and encryption where needed.
Reusable content also requires clear permission boundaries. Avoid mixing data belonging to different users or business contexts.
Tasks involving financial, legal, or other high-risk decisions should retain the necessary review and validation mechanisms. Cost optimization can improve execution, but it must not reduce accountability.
8. Conclusion: Optimize the Complete Task, Not Just the Unit Price
Time-based pricing and price reductions create new opportunities to lower LLM inference costs. The effective approach, however, is not simply to avoid peak periods. It is to build an engineering system in which costs can be calculated, workloads can be scheduled, and outcomes can be monitored.
Prioritize user experience for real-time tasks and schedule delay-tolerant work during suitable off-peak windows. Reduce input before optimizing reuse, and align output length with business requirements. Evaluate savings using successful task completion, quality, latency, and total cost together.
When these practices form a closed loop, lower prices can translate into sustained business savings rather than a change confined to the pricing table.
