Subscription Quota Conversion: Analyzing Token Costs and Cache Hits
AI coding tools typically use subscription plans measured in internal credits rather than raw token counts, making direct price comparisons difficult. This article breaks down the four billing dimensions of large language models—cache read, fresh input, cache write, and output. It explains how to measure token deduction rates through isolated experiments and provides formulas to estimate the actual capacity of a subscription plan. Additionally, it covers the gap between theoretical and actual usage, engineering practices to improve cache hit rates, and a methodology for comparing subscription plans with pay-as-you-go billing.
1. Background: Why Subscription Quotas Are Hard to Compare Directly
In recent years, most AI coding tools aimed at developers have adopted subscription plans. These plans usually specify a monthly usage quota, but the unit is often an internal metric or credit rather than request counts or token numbers. What users see in the UI is an integer percentage, making it impossible to know exactly how many credits one million tokens consume.
This creates two problems. First, it is impossible to directly align the plan price with the token-based pricing of pay-as-you-go APIs, because subscription schemes imply varying discount coefficients for different token types. Second, the actual capacity of the same plan varies significantly depending on the usage pattern. To determine if a plan is cost-effective, you must first understand its billing structure and then estimate based on your own load characteristics.
2. The Four Token Billing Dimensions
Mainstream large language model services typically split a single request’s input and output into four metered categories, each with a distinct cost structure.
- (1) Cache Read (Cache Hit Input): The request prefix is completely identical to a recent request. The server directly reuses the pre-computed intermediate states without recalculating from scratch. These tokens have the lowest compute cost and are billed at the lowest coefficient.
- (2) Fresh Input (Cache Miss Input): New content that the server must process from the beginning, including new user messages, newly read file fragments, or tool return results. These tokens have the highest compute cost and are usually billed at the highest input coefficient.
- (3) Cache Write: The cost incurred when writing a prefix to the cache for the first time. The write process requires additional storage and compute, so its unit price might be higher than a standard fresh input, but it drastically reduces costs on subsequent reuse.
- (4) Model Output: The content generated by the model. Generation happens token by token, which is time-consuming and compute-heavy. The unit price is typically significantly higher than any input token.
Understanding these four categories is the foundation for all subsequent estimations. The caching mechanism relies on the condition of an “exact prefix match.” As long as the system prompt, tool definitions, or the order of historical messages change, the cache is invalidated, and that content will be billed again as fresh input.
3. How to Measure the Deduction Rate of Each Token Type
Since the UI only displays integer percentages, the consumption of a single request cannot be read directly. A viable approach is to design isolated experiments where each group of requests only amplifies the consumption of one token type, and then track the quota changes.
- (1) Cache Read Test: First write a fixed, long context, then repeatedly send identical prefixes so that the vast majority of tokens hit the cache.
- (2) Fresh Input Test: Replace the input content in every request to avoid hitting the cache, ensuring all input is billed as fresh.
- (3) Output Test: Construct requests that require long generations, making output tokens the dominant proportion.
- (4) Data Recording: Whenever the percentage drops from one integer to the next (e.g., from 17% to 18%), record the cumulative number of that specific token type consumed during that interval.
Since each interval represents a fixed 1 percentage point, the average of multiple complete intervals can offset the rounding errors at the beginning and end. The formula is as follows:
Rate per million tokens = (Total percentage points crossed / Total tokens consumed for this type) × 1,000,000
Below is a schematic calculation script with generic variable names:
def rate_per_million(interval_tokens, pct_per_interval=1.0):# interval_tokens: The cumulative number of a specific token type within each complete percentage point intervaltotal_tokens = sum(interval_tokens)total_pct = pct_per_interval * len(interval_tokens)return total_pct / total_tokens * 1_000_000
Two things should be noted during the experiment. First, each test group should maintain a single variable to avoid mixing in other token types. Second, each type of test should be repeated multiple times and ideally completed within a similar timeframe to minimize interference from server-side policy adjustments.
4. From Deduction Rates to Quota Capacity
Once the four deduction rates are measured, you also need to know the proportion of each token type in your actual workload. Let the proportions of each token type be w1 to w4, and their respective deduction rates be r1 to r4. The weighted cost per million tokens of workload is:
Weighted Cost = w1·r1 + w2·r2 + w3·r3 + w4·r4
If the total quota of the plan is Q (measured in percentage points), the theoretical capacity is approximately:
Theoretical Token Capacity ≈ Q ÷ Weighted Cost × 1,000,000
The key to this formula lies in the proportions (w). For the same plan, if the workload is dominated by long context reuse with a high cache read proportion, the weighted cost is low, and the capacity is high. If the workload frequently switches tasks and constantly introduces new files, the fresh input proportion is high, and the capacity drops noticeably. Therefore, the “usable amount” of a plan is not a fixed value, but a variable determined by the load structure.
5. The Gap Between Theoretical and Actual Values
A common assumption in third-party estimates is: 97% cache read, 2.5% fresh input, and 0.5% output. Under this ratio, the average cost per token is minimized, yielding the highest possible capacity. This is closer to a theoretical upper limit rather than the real-world usage pattern for most people.
In actual usage, several factors will lower the effective capacity:
- (1) Task Switching: Different tasks use different contexts, preventing prefix reuse and lowering the cache hit rate.
- (2) Cache Expiration: Caches typically have a time-to-live (TTL). After a long pause, identical prefixes must be recalculated.
- (3) Prefix Changes: Modifying system prompts, adjusting the tool list, or changing the message order all invalidate the cache.
- (4) Context Bloat: As the conversation gets longer and historical messages increase, the proportion of fresh input may gradually rise.
This is similar to the difference between a device’s nominal battery life and its real-world endurance. Nominal values are measured under ideal conditions, while daily use—with frequent starts and stops, high loads, and environmental changes—degrades actual performance. Therefore, when evaluating a plan, you should base your estimates on your actual usage distribution over a period of time, rather than directly adopting the ideal ratios provided by vendors or third parties.
6. Engineering Practices to Improve Cache Hit Rates
The most effective way to reduce unit cost is usually to improve the cache hit rate. The following practices are applicable in most scenarios:
- (1) Stable Prefixes: Place content that rarely changes, such as system instructions and tool definitions, at the very beginning of the request, and put dynamic content at the end.
- (2) Maintain Serialization Consistency: The string generated for the same configuration must be byte-for-byte identical every time; otherwise, the cache cannot match it.
- (3) Batch by Task: Process similar tasks in batches to reduce context switching within the cache TTL.
- (4) Trim Context: Regularly compress historical conversations into summaries and limit the length of tool return content to prevent the accumulation of invalid tokens.
- (5) Control Output: Use explicit instructions and maximum length limits to avoid extra output consumption from verbose answers.
- (6) Monitor Hit Rates: Record the number of each token type in the logs for every request, and track cache hit rates by day or by project. In enterprise environments, you can leverage logging services and monitoring alerts to set hit rate thresholds and trigger timely notifications.
7. Comparing Subscription vs. Pay-As-You-Go
When comparing the two billing methods, you should use the “effective cost per completed task” as your unit of measurement, rather than just looking at the plan price or the unit price list. The recommended steps are as follows:
- (1) Collect Data: Gather usage logs for at least one to two weeks and count the volume of the four token types.
- (2) Calculate Proportions: Derive the actual load structure (w1 to w4).
- (3) Estimate Costs: For pay-as-you-go, directly weight the official unit prices of each token type with their proportions. For subscription plans, divide the plan price by the theoretical capacity and adjust by the actual load proportions.
- (4) Consider Hidden Limits: Include concurrency limits, rate limits, and model availability. These factors do not appear in the unit price but will affect actual output.
- (5) Periodic Retesting: Service rules may change, and both deduction coefficients and plan quotas can be updated. It is recommended to recalculate periodically.
8. Conclusion and Recommendations
The hidden quota of a subscription plan is essentially a combination of discount coefficients set by the service provider for different token types. Cache reads are cheap, while fresh inputs and outputs are more expensive. The actual value of a plan depends on the user’s load structure.
For developers and teams, there are three main recommendations. First, conduct your own estimations using your log data instead of relying on ideal ratios. Second, invest engineering effort into improving cache hit rates and controlling context scale; this usually yields greater returns than simply switching plans. Third, always base your evaluations on effective task costs and review them periodically to adapt to changes in billing rules.
Regardless of the billing method chosen, clear usage data is the prerequisite for making an informed decision.
