Choosing LLMs and Controlling Costs After Cache Pricing Hikes
Large Language Model (LLM) API prices are becoming increasingly difficult to compare directly, as some providers have adjusted their billing rules for cache hits, leading to unexpectedly high bills. This article explains how to understand cache billing details, select models using real-world traffic data, and implement architectural optimizations to control costs effectively.
The pricing of Large Language Model (LLM) APIs is becoming increasingly difficult to compare directly. Some providers have adjusted their billing rules for cache hits, meaning the same business workload can result in a bill several times higher than before. For teams that have budgeted based on old prices, a single price adjustment can lead to cost overruns. Model selection and cost reduction must be based on detailed billing rules and real traffic data, rather than just the unit price on the rate card.
1. Understanding the Billing Rules for Cache Hits
When processing long texts or repeated contexts, LLMs use KV Cache to store previously calculated intermediate results, avoiding redundant computation. This reduces the first token latency and lowers compute consumption. To encourage developers to optimize their request structures, providers typically offer discounts on input tokens that hit the cache. Recently, some models have multiplied the unit price for cache hits by several times, shrinking the discount margin.
Suppose a particular plan, under the original billing rules and with optimized caching, could support about 7 billion tokens of consumption per month. If all requests hit the cache, the budget remains fixed, and the cache hit unit price increases to 5 times its original rate, the theoretically available tokens drop to one-fifth of the original amount, or about 1.4 billion. This is an idealized extreme scenario. The actual impact depends on the cache hit ratio: the higher the hit ratio, the greater the impact of the price adjustment; if the hit ratio is zero, the adjustment barely affects the bill.
You can use the following formula to estimate monthly costs by plugging in your own billing data:
Monthly Cost = Input Token Count × [Cache Hit Ratio × Hit Unit Price + (1 − Cache Hit Ratio) × Miss Unit Price] + Output Token Count × Output Unit Price
Note that the cache hit ratio must be calculated from the usage details returned by the provider; it cannot be replaced by an estimated value. System Prompts, historical dialogue records, and fixed tool definitions typically have the highest hit rates, so you should closely inspect the billing rules for these components.
2. Model Selection: Using Real Corpora Instead of Price Comparisons
Different providers use different tokenizers. The same piece of text—whether it is Chinese, code, or a mix of both—may convert to very different token counts across different models. Therefore, directly comparing the listed API prices is of limited value.
1. Conduct Consumption Tests with Real Business Corpora
Extract high-frequency requests from production logs, covering long and short texts, mixed languages, and mixed code/natural language. Send the same batch of requests to candidate models respectively, and record the actual charges. It is recommended to organize the results in a table like the one below:
| Scenario | Sample Size | Model | Counting Method | Actual Charge (Local Currency) | Cost per 10k Calls | Error Rate | Statistical Period |
|---|---|---|---|---|---|---|---|
| Customer Service Q&A | 500 | Model A | Per provider docs | To be filled | To be filled | To be filled | 7 consecutive days |
Cost per 10k Calls = Total Charge during the statistical period ÷ Number of Calls × 10000. The statistical period should cover a complete business fluctuation cycle; otherwise, traffic differences between weekdays and weekends will skew the results.
2. Verify Concurrency Limits and Availability
Some models have low unit prices but impose strict limits on QPS (queries per second), TPM (tokens per minute), or RPM (requests per minute). High-concurrency consumer-facing applications or batch processing tasks on the enterprise side may experience significant queuing and timeouts as a result.
During stress testing, incrementally increase concurrency and record P95 and P99 latencies, as well as the rate of 429 (rate limiting) and timeout errors. Identifying the concurrency point where the error rate begins to rise significantly helps estimate the model’s available capacity. Before going live, you should also determine the following parameters, with specific values adjusted according to your business SLA requirements:
- Timeout: For example, set to approximately 1.5 times the model’s P95 latency.
- Retry Strategy: Use exponential backoff for 429s and timeouts, with a maximum of 2 retries.
- Circuit Breaker Threshold: For example, automatically switch to a backup model if a particular model’s error rate exceeds a set value within 5 minutes.
3. Review Financial and Compliance Conditions
Technical metrics serve as a baseline for selection, but contracts and financial terms determine whether the solution can be practically deployed. Enterprises should verify the following items before procurement:
- Contract Terms: Whether advance notice is required for billing method changes, and whether there is an agreed effective date for price adjustments.
- SLA: Availability commitments, compensation methods, and incident response times.
- Payment and Invoicing: Available payment methods for corporate transactions and the ability to issue official invoices.
- Data Compliance: Whether data will be transferred across borders, whether it will be used for model training, how long logs are retained, and whether they can be deleted.
Low-cost packages aimed at individual developers often fall short on the above criteria. They are suitable for testing or prototyping but should not directly support core enterprise workloads.
3. Cost Reduction Strategies: From Request Structure to Call Counts
To cope with price adjustments, a more effective approach than passively switching providers is to reduce the cost per request and the total number of calls through engineering architecture. The following methods can be used in combination.
1. Context Pruning
For long conversations, the complete history records should not be sent to the model with every request. A common approach is to keep only the most recent N rounds of dialogue
