AI Subscription Quotas: Reverse-Engineering Real Usage from Floating-Point Values

    An unrounded usage value returned by an AI assistant’s API can reveal more than a progress bar. This article explains how to use continued fractions and the Stern-Brocot tree to recover the underlying rational fraction, reconstruct a credit-based quota model across subscription tiers, and derive practical lessons for API precision, reverse engineering, and evaluating usage-based plans.

    AI Subscription Quotas: Reverse-Engineering Real Usage from Floating-Point Values

    1. A Suspicious Decimal That Sparked an Investigation

    Many developers who use AI assistant subscription services are accustomed to a “use until it runs out” experience: the interface shows a vague usage percentage, and ordinary users can hardly tell how much quota remains or how much difference there is between tiers. Platforms usually provide only a rounded progress bar, while the real numbers stay hidden in the backend.

    The trigger, however, was unexpectedly simple: the server forgot to round a decimal.

    A observant programmer, while inspecting usage data returned by a web API, found a “strange” floating-point number: 0.16327272727272726. Seventeen decimal places—suspiciously precise. A casually written percentage or a deliberately designed usage ratio usually does not look like this. Such an unusually long mantissa often means it is the raw result of an exact fraction divided by some integer, without further processing—for example, a value like 179 / 1100.

    This finding meant that the platform’s internal quota metering system was real and computable, and it was “running naked” through an unrounded API return value. The next step was to “translate” this floating-point number back into its original fractional form.

    2. The Stern-Brocot Tree: Recovering a Fraction from a Float

    How can we infer the most likely original fraction from a decimal? This is a classic problem in number theory: best rational approximation. Two common tools are:

    • Continued fraction expansion: Expand the decimal step by step into the form [a0; a1, a2, ...], then truncate to obtain best approximations with progressively larger denominators.
    • Stern-Brocot tree: A binary search tree that organizes all positive rational numbers according to the mediant rule, allowing systematic search for the fraction closest to the target decimal under a constraint such as “denominator not exceeding N.”

    These two methods are mathematically equivalent in essence and are not difficult to implement. A simplified Stern-Brocot approximation example is shown below:

    1. def approximate_fraction(target, max_denominator=10000):
    2. lo_num, lo_den = 0, 1 # Lower bound 0/1
    3. hi_num, hi_den = 1, 0 # Upper bound 1/0 (infinity)
    4. while True:
    5. med_num = lo_num + hi_num
    6. med_den = lo_den + hi_den
    7. if med_den > max_denominator:
    8. break
    9. med = med_num / med_den
    10. if abs(med - target) < 1e-12:
    11. return med_num, med_den
    12. if med < target:
    13. lo_num, lo_den = med_num, med_den
    14. else:
    15. hi_num, hi_den = med_num, med_den
    16. return lo_num, lo_den # Or choose the closer side
    17. print(approximate_fraction(0.16327272727272726))
    18. # Output close to the simple fraction 179 / 1096 ≈ 0.16327…

    The key insight is: if the returned value is precise to the limit of double-precision floating point, approximating it under a reasonable denominator constraint will almost always hit a unique simple fraction. Once the fraction is obtained, combined with comparison data from multiple scenarios, the platform’s complete internal quota model can be pieced together.

    3. Piecing Together the Full Quota Ledger

    Through multiple samples—progress values captured at different times and under different usage states—the developer inferred that the service internally uses “credits (compute credits)” as a unified unit of measurement, and derived a conversion relationship highly consistent with public API pricing:

    Dimension Consumption ratio (illustrative)
    Flagship large model About 1.67x the standard model
    Lightweight model About 1/5 of the standard model
    Output tokens About 5x input tokens

    This ratio structure is fully consistent with public API pay-as-you-go pricing, indicating that subscription plans and the API share the same cost accounting system, just with different pricing methods.

    On this basis, the real quotas of each tier emerged (values are illustrative reconstructions):

    • Entry tier (~$20/month): About 550k credits per 5-hour window, with a weekly cap of about 5M credits—this is the baseline.
    • Advanced tier (~$100/month, marketed as 5x usage): Measured at about 3.3M credits per 5 hours, i.e., 6x the baseline; weekly cap of about 41.66M credits, i.e., 8.33x the baseline.
    • Flagship tier (~$200/month, marketed as 20x): By proportional inference, the actual quota is likewise higher than the nominal multiplier.

    In other words, higher-priced tiers quietly provide more quota. The platform uses integer multipliers such as “5x” and “20x” as marketing anchors, but internal calculations may involve rounding up, stacked coefficients, or window-mechanism differences, causing real quotas to exceed advertised values. For budget-heavy teams, this is concrete value information: quota per dollar is actually cheaper in the higher tier.

    4. Methodology Lessons from This Case

    The value of this case goes far beyond “getting insider pricing information.” It offers developers three general methodologies:

    1. API return values are a high-risk area for information leakage.
    Whether developing your own service or auditing a third-party system, be wary: if fields such as progress percentages, quota remaining, and rate limits return unrounded raw floating-point values, they may leak the internal billing model. The best defensive practice is to apply uniform precision handling at the egress point:

    1. # Defensive approach: expose only rounded percentages
    2. usage_ratio = used_credits / total_credits
    3. safe_response = {"usage_percent": round(usage_ratio * 100, 1)}

    2. Floating-point numbers often hide a rational number behind them.
    Whenever you see a “precise” value with more than ten decimal places, be alert: it most likely comes from an integer / integer calculation. Combined with continued fractions or Stern-Brocot tree approximation, internal parameters can be recovered. This is very useful for reverse-engineering black-box mechanisms such as quotas, probabilities, and sampling rates.

    3. When choosing a plan, calculate “quota per unit price,” not marketing multipliers.
    When evaluating any usage-based subscription service—whether an AI assistant, an API call bundle, or a cloud resource plan—build your own accounting table: list price per tier, window quota, period cap, and model consumption multiplier clearly; calculate how much effective compute each dollar buys; then choose a tier based on your own peak usage. For enterprise users, a more prudent approach is to plan such elastic compute demands separately from stable cloud infrastructure (such as object storage, message queues, logging, and monitoring)—use mature platforms to carry deterministic base workloads and manage fluctuating AI invocation costs separately.

    5. Conclusion

    A decimal that missed rounding and a set of old number theory tools reconstructed a complete commercial pricing logic. This reminds us that in a data-intensive era, any number exposed externally is a potential reverse-engineering entry point. For defenders, it is a lesson in precision governance; for analysts, it is a reward for observation; and for ordinary users, it is a vivid lesson in consumption—only by understanding the real quota ledger can you give a data-based answer to “which subscription is the best value,” rather than an answer based on marketing language.