LLM Token Quotas and Cost Conversion: A Practical Estimation Guide

    Large language model billing and quota rules can interact in ways that make nominal budgets misleading. This article explains how to distinguish input, cache-read, and output tokens; calculate per-request cost; estimate how many requests a quota can support; apply monthly, periodic, and sliding-window limits; avoid common estimation errors; and use a short Python script to support capacity planning and usage monitoring.

    1. Background: Quota and Billing Constraints Are Easy to Miscalculate

    Large language model services often impose two constraints at the same time. One is the billing rule: each call is charged according to token count and unit price. The other is the quota rule: the amount of money or number of calls that can be consumed within a certain time range is capped. When these two rules overlap, users often see only the nominal quota and overlook the practical impact of period splitting, per-window limits, and reset times.

    The nominal quota is the total amount registered in the account. The available quota is the portion that can actually be consumed in the current time period. The gap between the two depends on the levels of limits and the refresh mechanism.

    2. Core Concepts to Separate

    Before estimating cost, it is necessary to distinguish several types of tokens.

    • Regular input tokens: input content that does not hit cache and must be fully processed. The unit price is usually the highest.
    • Cache-read tokens: input content that matches a historical request prefix and can reuse cache. The unit price is usually significantly lower than that of regular input.
    • Output tokens: content generated by the model. The unit price is generally higher than that of input.

    Billing prices are often expressed as an amount per million tokens. This means that when converting, you must first divide the token count by one million and then multiply by the unit price; otherwise, the result can be off by more than a factor of 1,000.

    3. Deriving Capacity from Per-Request Cost

    The cost of a single request can be calculated with the following formula:

    Per-request cost = regular input tokens × input price ÷ 1,000,000 + cache-read tokens × cache-read price ÷ 1,000,000 + output tokens × output price ÷ 1,000,000

    Assume a request contains 700 regular input tokens, 52,000 cache-read tokens, and 150 output tokens. The prices are CNY 1.0 per million input tokens, CNY 0.2 per million cache-read tokens, and CNY 4.0 per million output tokens. The cost of this request is calculated as follows:

    • Regular input: 700 × 1.0 ÷ 1,000,000 = CNY 0.0007
    • Cache read: 52,000 × 0.2 ÷ 1,000,000 = CNY 0.0104
    • Output: 150 × 4.0 ÷ 1,000,000 = CNY 0.0006
    • Total: approximately CNY 0.0117

    Once the per-request cost is known, you can work backward to estimate how many requests a quota can support. For example, a CNY 100 quota can support about 8,500 requests of the same type. Note that the prices in this example are illustrative only. Actual prices should be based on the service provider’s console or official price list. When deploying model services on a cloud platform such as Baidu AI Cloud, the same framework can be applied.

    4. How Multiple Limits Stack

    Common quota designs include three types:

    1. Monthly quota: the total amount available to the account within one billing month.
    2. Periodic cap: for example, a maximum percentage of the monthly quota that can be consumed per week.
    3. Sliding-window cap: for example, a maximum percentage of the monthly quota that can be consumed every 5 hours.

    The actual available quota is the minimum of all limit layers, and it must be judged together with the current position in time. Assume a monthly quota of CNY 1,000, a weekly cap of 50% (CNY 500), and a 5-hour window cap of 20% (CNY 200). To exhaust the weekly cap of CNY 500, at least 3 five-hour windows are needed, because 2 windows can consume only CNY 400.

    This calculation shows that window length and period boundaries directly affect the effective quota. If only a few days remain in a week, then even if the nominal quota is large, the portion that can be consumed will shrink significantly.

    5. Common Estimation Mistakes

    Mistake 1: Treating the nominal quota as the available quota. The monthly total usually cannot be fully consumed within one week. You should first take the minimum of all limit layers and then calculate the available amount within the remaining time.

    Mistake 2: Ignoring period splitting. If the quota resets on a certain weekday, or the quota is valid only before a specific date, the effective number of days is reduced. Estimates should be based on the actual effective interval.

    Mistake 3: Ignoring cache differences. In scenarios with long contexts and many repeated prefixes, the share of cache-read tokens is high, and the per-request cost will be significantly lower than if all input were assumed to be regular input. Conversely, tasks with longer output will have higher costs. Statistics should be collected separately according to the actual request structure.

    Mistake 4: Treating total token volume directly as request count. There is no fixed relationship between total token volume and request count. You need to convert using the actual average number of tokens per request.

    6. Estimating with Code

    The following script demonstrates how to combine unit prices, request structure, and quota parameters for calculation. The prices are example values:

    1. # Price unit: CNY per million tokens (example values; refer to the official price list)
    2. PRICE_PER_M = {"input": 1.0, "cache_read": 0.2, "output": 4.0}
    3. def request_cost(input_tokens: int, cache_tokens: int, output_tokens: int) -> float:
    4. p = PRICE_PER_M
    5. total = (input_tokens * p["input"]
    6. + cache_tokens * p["cache_read"]
    7. + output_tokens * p["output"])
    8. return total / 1_000_000
    9. def capacity(budget: float, per_request: float) -> int:
    10. """Estimate the number of supported requests for a given available amount."""
    11. return int(budget // per_request)
    12. def windows_needed(weekly_cap: float, window_cap: float) -> int:
    13. """Estimate the minimum number of windows needed to exhaust the weekly cap."""
    14. return -(-weekly_cap // window_cap) # round up
    15. if __name__ == "__main__":
    16. cost = request_cost(700, 52_000, 150)
    17. print(f"Per-request cost: {cost:.4f} CNY")
    18. print(f"Requests supported by 100 CNY: {capacity(100, cost)}")
    19. print(f"Windows needed to exhaust the weekly cap: {windows_needed(500, 200)}")

    After running, the script outputs the per-request cost, the number of supported requests, and the number of windows needed to exhaust the weekly cap. Replace the example values with real prices, limits, and log statistics to obtain estimates that are closer to actual usage.

    7. Verification and Monitoring Recommendations

    Estimation is only an ex ante judgment. During actual execution, continuous verification is also needed.

    • Use console usage as the source of truth: regularly compare script estimates with usage data returned by the platform, and correct price or request-structure assumptions promptly if deviations are found.
    • Group statistics by request type: distinguish short Q&A, long-context, and tool-call requests, and record average token counts and cache hit rates separately.
    • Set usage alerts: send notifications when 80% of the weekly cap or window cap is reached, so that quota does not run out in the middle of a critical task.
    • Validate in batches: before large-scale calls, use a small batch of requests to validate the cost model and confirm that per-request cost and limit-triggering rules match expectations.

    8. Summary

    The actual available quota of a large language model service is determined jointly by billing unit prices, request structure, and multi-level limits. When estimating, you should first break down token types, calculate per-request cost, then take the minimum of all limit layers, and judge the effective period together with time windows. By codifying this process in a script and continuously verifying it against actual usage, you can convert a nominal quota into a reliable capacity expectation and plan call volume and budget more reasonably.