How to Measure Programming Subscription Credits: A Reproducible Capacity Algorithm

    Many AI programming subscriptions charge based on internal credits rather than raw tokens, displaying only integer percentages that make it difficult to evaluate true plan value. This article introduces a reproducible method for estimating token consumption coefficients through single token type isolation, multi-interval sampling, and workload weighting. By correcting ideal cache hit rates with actual usage patterns, developers can accurately calculate subscription capacity and objectively compare different plans.

    1. Why Reverse-Engineer Subscription Credits?

    Most programming subscriptions do not charge by raw tokens; instead, they deduct internal credits or points. The user interface typically only displays the integer percentage of remaining credits, leaving users unable to determine how many tokens were consumed for input, output, or cache hits. Simply comparing monthly fees makes it easy to choose the wrong plan. Two plans with identical monthly fees might perform very differently: one might only support a few long-context requests, while another can handle many more lightweight requests.

    To compare cost-effectiveness, you must first experimentally estimate the consumption coefficient for each token type, and then calculate the total capacity of the plan based on your actual usage habits. Only with this number can you accurately compare different plans horizontally.

    The cache hit rates advertised by service providers are usually ideal values. If you estimate capacity using these ideal hit rates, the results will be significantly inflated. The correct approach is to correct them using the actual proportion in your workload. A comparative example is provided in Section 3.

    2. A Reproducible Measurement Method

    Before starting, please note the following. These tests send real requests, which may incur extra costs, trigger rate limits, or violate terms of service.

    • Read the provider’s terms of service first to confirm whether automated testing is allowed. Do not test if prohibited.
    • Only use your own account and API keys. Do not test others’ accounts or share keys. Store keys in environment variables; do not hardcode them in scripts or logs.
    • Set a budget cap and a request frequency limit, and stop when exceeded. Monitor rate limit warnings and account status during testing.
    • The numbers in this article are for illustrative purposes only. Always refer to the provider’s usage reports for actual results.

    This method revolves around three core concepts: isolating a single token type, multi-interval sampling, and weighting by workload.

    All experiments must be conducted under uniform conditions: a concurrency of 1, fixed temperature, max_tokens, and stop conditions. For each request, record the following fields for future verification:

    • Experiment type, request time, input token count (split into hit, miss, and write), and output token count
    • Credit readings before and after the request, as well as the interval number
    • Concurrency status, cache status (enabled, new prefix created)
    • Anomaly notes, such as truncation, rate limiting, or billing delays

    2.1 Isolating a Single Token Type

    Each test should amplify the consumption of only one token type while keeping others as small as possible. After each request, read the detailed numbers in the usage report to confirm the actual quantity of each token type.

    Testing Missed Input: First, disable automatic caching. If the provider offers an option to disable caching or an uncached API endpoint, use it. If not, wait for the cache to expire (refer to the provider’s documentation for TTL), then send requests with completely different content. After sending, check the usage report to confirm the cache write count is 0. If the write count is not 0, this data set has mixed in cache writes and should be discarded.

    Testing Cache Hit Input: First, send a fixed long context to allow the provider to write it to the cache. Subsequent requests should use the same prefix, keeping the session context from growing. The first request should be recorded separately and not included in the hit samples, as it generates a cache write. After each request, confirm that the hit token count in the report is close to the entire input.

    Testing Cache Write: You cannot simply measure this by changing the prefix every time. Doing so introduces missed input on each request, making it impossible to separate the two consumption types. Instead, use a controlled experiment:

    • Control Group: The input length is L tokens, the cache has expired, and the usage report shows 0 writes. Record the consumption ΔE₀ for this request.
    • Experimental Group: The input length is also L tokens, but using a completely new prefix. The usage report should show L writes. Record the consumption ΔE₁.
    • The output length for both groups must be identical, so the output consumption cancels out.

    The difference between the two groups comes only from the input type. The consumption coefficient for cache write is:

    Cache Write Coefficient = Missed Input Coefficient + (ΔE₁ − ΔE₀) × 10⁶ ÷ L

    Where the Missed Input Coefficient is taken from the previous isolated measurement. The unit for ΔE is credit percentage points, and L is the input token count per request.

    Testing Output: Elongate the output length individually while keeping the input as short as possible. Set a fixed max_tokens and stop condition, and discard any samples that were truncated due to hitting the limit. Otherwise, the output limit will be mistakenly treated as the consumption coefficient.

    2.2 Multi-Interval Sampling

    Interfaces typically only display integer percentages. If the consumption of a single request is much less than 1%, the reading is almost useless. Therefore, you need to continuously send a large number of requests and record the cumulative token consumption during the period when the credit percentage jumps from one integer to the next. Each complete interval yields one sample. By averaging multiple samples, you can determine how many credit percentage points are consumed per million tokens of a specific type.

    Follow these rules during implementation:

    • Only use intervals that are complete at both ends. Incomplete intervals at the beginning or end should be discarded.
    • Try to avoid requests that cross interval boundaries. When approaching a boundary, estimate the single-request consumption based on the average of previous requests, and reduce the output length so the estimated consumption is less than the remaining distance. Stop before the boundary and do not send requests that might cross it.
    • If crossing a boundary is unavoidable, apportion the token count for that request proportionally between the two intervals, and note the boundary margin (the difference before and after the reading jump) in your records.
    • Ensure a sufficient sample size. Complete at least 5 full intervals for each token type and calculate the dispersion. If the coefficient of variation exceeds 15%, first check for concurrent requests, cache invalidation, or billing delays. Identify the cause before deciding to retest or discard the data.
    • After a reading jump, wait for the credit reading to stabilize before recording it to avoid errors caused by billing delays. The waiting time should be determined by actual observation.

    2.3 Weighting by Workload

    Once you have the consumption coefficients for each token type, weight them according to their proportions in a real workload to estimate the total capacity.

    • Workload proportion pᵢ: The ratio of the i-th token type to all tokens, where the sum of all types equals 1.
    • Consumption coefficient cᵢ: The number of credit percentage points consumed per million tokens of the i-th type.

    The weighted average consumption is Σ(pᵢ × cᵢ), measured in credit percentage points per million tokens. Assuming the total credit is 100%:

    Effective Tokens (Millions) = 100 ÷ Σ(pᵢ × cᵢ)

    If credits are expressed in other units, convert them to percentages first.

    Applicability Boundaries: The above formula only applies to plans where credit consumption is approximately linearly additive. That is, the credit for each request is proportional to the token count, with no fixed fees per request, no tiered billing, and consistent multipliers across different models or token types. If the plan has any of these characteristics, you must measure them by layer, model the capacity separately for each model or tier, and then calculate the capacity individually.

    Below is a demonstration using a set of hypothetical numbers. These figures are not actual test results and are only used to illustrate the formula. Suppose a plan has the following consumption coefficients (in credit percentage points per million tokens): Cache Hit Input 0.10, Missed Input 1.00, Cache Write 1.25, Output 5.00. Two workload structures are shown below:

    Token Type Coefficient cᵢ Scenario A pᵢ Scenario A pᵢ×cᵢ Scenario B pᵢ Scenario B pᵢ×cᵢ
    Cache Hit Input 0.10 0.70 0.0700 0.40 0.0400
    Missed Input 1.00 0.10 0.1000 0.30 0.3000
    Cache Write 1.25 0.05 0.0625 0.10 0.1250
    Output 5.00 0.15 0.7500 0.20 1.0000
    Total 1.00 0.9825 1.00 1.4650

    In Scenario A, Σ(pᵢ × cᵢ) is 0.9825, yielding an effective token capacity of about 100 ÷ 0.9825 ≈ 101.8 million. In Scenario B, Σ is 1.4650, yielding an effective token capacity of about 100 ÷ 1.4650 ≈ 68.3 million.

    For the same plan, different workload structures result in a capacity difference of about 30%. Therefore, when selecting a plan, you must use your actual workload proportions rather than applying generic ratios.

    3. Correcting Theoretical Values with Actual Workloads

    Suppose a provider advertises a cache hit rate of 90%. Calculating with the ideal proportions: Cache Hit 0.90, Missed Input 0.04, Cache Write 0.01, Output 0.05. Σ = 0.0900 + 0.0400 + 0.0125 + 0.2500 = 0.3925, yielding a theoretical capacity of about 254.8 million tokens.

    In an actual workload, however, the cache hit proportion might only be 70%, and the output proportion is higher. As calculated in Scenario A, the capacity is about 101.8 million tokens. The theoretical value is about 2.5 times higher than the actual value. The ideal hit rate masks the consumption from missed input and output.

    Therefore, when evaluating plans, you should rely on the proportions of various token types from your actual usage reports. Theoretical values can only serve as an upper-bound reference and should not be treated as actual capacity.

    4. How to Choose: Comparing Plans by Capacity

    1. Use the same method to measure the consumption coefficients of two plans.
    2. Tally the proportions of various token types from your usage reports over the past month.
    3. Calculate the effective token capacity for each plan separately, then divide the monthly fee by the effective token capacity to get the unit cost.

    When comparing, note two things. First, measurement conditions must be consistent, including the model, context length, and output length. Second, capacity will change with your usage habits, so it is best to retest periodically.

    5. Common Mistakes

    • Treating the theoretical cache hit rate as the actual value.
    • Directly extrapolating from a single request’s reading, ignoring the precision limitations of integer percentages.
    • Not recording cross-interval requests, leading to sample distortion.
    • Changing the prefix every time when testing cache writes, mixing missed input with cache write.
    • Ignoring applicability boundaries and applying the formula directly to plans with tiered billing or fixed fees.
    • Treating hypothetical numbers as actual test results.