LLM Token Quotas and Cost Estimation: A Practical Guide

    This article explains why nominal LLM credit quotas can be misleading and presents a practical method for estimating request costs, usable request volume, and token capacity under monthly, weekly, and rolling-window limits. It includes a worked example, a Python implementation, common pitfalls, and engineering recommendations.

    1. Background: Why Quota Numbers Are Easy to Misread

    LLM services meter usage by tokens, but many platforms issue quotas in currency units. A user may see a “monthly quota of 500 units,” but the actual number of tokens that can be processed depends on unit prices, input/output structure, cache hit rate, and other variables. Estimating capacity from the nominal quota alone can therefore overestimate or underestimate the actual usable amount.

    This article uses a hypothetical scenario to explain the calculation method: a service provides a monthly quota while also enforcing a weekly cap and a rolling-window cap. All numbers in this article are demonstration parameters and do not represent the pricing or limits of any real product.

    2. Three Core Concepts

    2.1 Token Count and Cost Are Different Metrics

    Token count measures the amount of text processed by the model, while cost measures the amount actually paid. The two are usually not proportional because different token types have different unit prices.

    A common billing breakdown includes three categories:

    • Regular input tokens: new context that does not hit the cache, usually at a higher unit price.
    • Cached read tokens: reused historical context, usually priced significantly lower than regular input.
    • Output tokens: content generated by the model, generally priced highest.

    2.2 Quotas Usually Have Three Layers

    • Periodic quota: the total amount available within one billing period.
    • Weekly cap: the maximum percentage that can be consumed in a single week, for example half of the total.
    • Rolling-window cap: for example, within any consecutive 5-hour period, at most a certain percentage of the periodic quota can be consumed.

    All three limits apply simultaneously. The actual usable amount is determined by the strictest layer, so you cannot rely only on the monthly total.

    2.3 Caching Can Make Token Counts Look Large

    In coding scenarios, each request often carries a large code context, most of which hits the cache. The total token count for a single request can reach tens of thousands while the cost remains low. If you multiply total tokens directly by the regular input price, the cost will be severely overestimated. The correct approach is to price each type separately and then sum the results.

    3. Calculation Steps

    The calculation can be divided into five steps:

    1. Profile the structure of a single request: how many tokens are new input, cached reads, and output.
    2. Calculate the cost per request by token type: cost per request = Σ(usage × unit price).
    3. Divide the quota by the cost per request to get the number of requests: requests = quota ÷ cost per request.
    4. Multiply the number of requests by the total tokens per request to get the total number of tokens that can be processed.
    5. Apply the weekly cap and the window cap separately, and take the minimum result across all layers.

    4. Worked Example

    Assume the following parameters:

    • Monthly nominal quota: 500 units
    • Weekly cap: 50% of the monthly quota, i.e., 250 units
    • Per-5-hour window cap: 20% of the monthly quota, i.e., 100 units
    • Unit prices (units per million tokens): regular input 1.00, cached read 0.20, output 4.00
    • Request profile: new input 700 tokens, cached read 52,000 tokens, output 150 tokens

    The cost per request is calculated as follows:

    • Regular input: 700 × 1.00 ÷ 10⁶ = 0.00070
    • Cached read: 52,000 × 0.20 ÷ 10⁶ = 0.01040
    • Output: 150 × 4.00 ÷ 10⁶ = 0.00060
    • Total: 0.01170

    The total token count per request is 52,850. This gives the following table:

    Limit dimension Quota (units) Requests Tokens processed
    Monthly nominal quota 500 ~42,735 ~2.259 billion
    Weekly cap 250 ~21,367 ~1.129 billion
    Per-5-hour cap 100 ~8,547 ~452 million

    This result shows two things. First, the nominal quota and the actual usable amount differ by a factor of two; the weekly cap directly halves the usable amount. Second, the window cap determines short-term throughput. With a weekly cap of 250 units and a maximum of 100 units consumed per window, consuming the full weekly quota requires at least 3 windows (250 ÷ 100 = 2.5, rounded up to 3).

    5. Code Implementation

    The code below implements the calculation flow above; you can replace the parameters with real values.

    1. from dataclasses import dataclass
    2. import math
    3. @dataclass
    4. class Pricing:
    5. input_per_m: float # Regular input price, units per million tokens
    6. cached_per_m: float # Cached read price, units per million tokens
    7. output_per_m: float # Output price, units per million tokens
    8. @dataclass
    9. class RequestProfile:
    10. new_input: int # New input tokens
    11. cached_input: int # Cached read tokens
    12. output: int # Output tokens
    13. def total_tokens(self) -> int:
    14. return self.new_input + self.cached_input + self.output
    15. def request_cost(p: Pricing, r: RequestProfile) -> float:
    16. """Price each token type separately and return the cost per request."""
    17. return (
    18. r.new_input * p.input_per_m
    19. + r.cached_input * p.cached_per_m
    20. + r.output * p.output_per_m
    21. ) / 1_000_000
    22. def capacity(budget: float, p: Pricing, r: RequestProfile) -> dict:
    23. """Estimate requests and processed tokens for a given budget."""
    24. cost = request_cost(p, r)
    25. requests = math.floor(budget / cost)
    26. return {
    27. "requests": requests,
    28. "tokens": requests * r.total_tokens(),
    29. }
    30. def windows_needed(weekly_cap: float, window_cap: float) -> int:
    31. """Minimum number of windows needed to consume the weekly cap."""
    32. return math.ceil(weekly_cap / window_cap)
    33. if __name__ == "__main__":
    34. pricing = Pricing(input_per_m=1.00, cached_per_m=0.20, output_per_m=4.00)
    35. profile = RequestProfile(new_input=700, cached_input=52_000, output=150)
    36. monthly = 500
    37. weekly = monthly * 0.5
    38. window = monthly * 0.2
    39. for name, budget in [("Monthly", monthly), ("Weekly", weekly), ("5-hour", window)]:
    40. result = capacity(budget, pricing, profile)
    41. print(f"{name}: {result['requests']} requests, {result['tokens']:,} tokens")
    42. print("Windows needed to consume the weekly cap:", windows_needed(weekly, window))

    After running it, you should get results consistent with Section 4. If you replace the parameters with real values, first verify the billing unit in the invoice and confirm whether the unit prices are given per million tokens or per thousand tokens.

    6. Common Pitfalls

    1. Treating the nominal quota as the usable quota and ignoring the weekly cap and window cap.
    2. Multiplying total tokens by the regular input price and ignoring the lower price of cached reads.
    3. Ignoring the start of the billing period. If usage starts in the middle of a period, the remaining quota and the weekly reset time are not aligned, and both the number of windows and the usable amount will change.
    4. Calculating only the theoretical maximum. Real usage also involves request length variation, failed retries, and concurrency contention.

    7. Engineering Recommendations

    • In usage monitoring, record the counts and corresponding costs of all three token types, and track them by type.
    • Reserve about 20% headroom for critical tasks to avoid interruption when the quota is near its limit.
    • Set alerts when approaching the window cap, and use queuing or degradation to maintain service stability.
    • Connect the estimation script to a budget dashboard, and periodically calibrate unit prices and request profile parameters against actual bills.