Subscription Cost Analysis: How to Reverse-Engineer AI Coding Tool Quotas from a Single Floating-Point Number

    This article breaks down the technical ledger behind AI coding tool subscriptions. Starting from an unrounded usage float returned by a web client, it shows how continued fraction expansion can recover the underlying quota fraction, how internal credit models weight tokens and model tiers, and why advertised tier multipliers often differ from measured ones. It then offers a practical cost model, a quota scheduling approach for multiple accounts, and an enterprise view focused on tiered routing, context governance, and centralized quota observability.

    1. Where It Started: A Number That Was Never Rounded

    Before asking which subscription tier is the best deal, there is a more basic question to answer: is the “remaining quota percentage” we see actually a trustworthy unit of measurement?

    A developer noticed that the usage field returned by the web client of an AI coding tool contained this floating-point value:

    1. 0.16327272727272726

    Seventeen decimal places, a repeating tail, suspiciously precise. No manually configured display value would ever look like this. It can only be the result of a division: the numerator is consumed internal metering units, the denominator is the total quota for that tier, and the frontend rendered it without rounding.

    The value of this observation is that it turns opaque billing into a linear system that can be solved in reverse.

    2. Method: Recovering a Fraction from a Float with Continued Fractions

    To recover a simplest-form fraction from a decimal float, the common approach is continued fraction expansion. Its geometric interpretation is a binary search on the Stern-Brocot tree: start from the interval (0/1, 1/1), repeatedly take the mediant of two adjacent fractions, and move left or right depending on the target value until the approximation error falls below a threshold.

    A sketch of the implementation:

    1. from fractions import Fraction
    2. def recover_fraction(x: float, max_denominator: int = 10**7) -> Fraction:
    3. """Recover the simplest fraction for a float via continued fraction expansion"""
    4. return Fraction(x).limit_denominator(max_denominator)
    5. # 0.16327272727272726 -> roughly 9/55.1; calibrate the denominator with batch data
    6. print(recover_fraction(0.16327272727272726))

    Three engineering caveats:

    • A single data point is not reliable. Floats carry representation error, so collect multiple samples and use a common multiple of the denominators as the candidate total quota.
    • Cross-validate. Sample the same account across different time windows; the conclusion only holds if the recovered denominator stays stable.
    • Focus on ratios, not absolute values. What carries over is the multiplier relationship between tiers.

    3. The Metering Model: Internal Credits and Conversion Factors

    Tools like this generally do not bill by “number of calls.” They maintain an internal credit system (think compute credits), for a simple reason: costs vary enormously across models and across input and output lengths, so a flat call count would be badly distorted.

    From publicly stated pricing relationships, a set of general conversion rules can be abstracted:

    • Model tier differences: the strongest reasoning model consumes roughly 1.6–1.7x a mid-tier model, and about 5x a lightweight model.
    • Input vs. output differences: output-side consumption is typically around 5x the input side.
    • Window constraints: a short rolling window quota and a long cumulative cap exist at the same time, and whichever is hit first takes effect.

    Expressed as a formula, the cost of one request:

    1. cost = (tokens_in * w_in + tokens_out * w_out) * model_factor
    2. where w_out ≈ 5 * w_in, model_factor(strong) ≈ 1.67, model_factor(light) ≈ 0.2

    This model has strong explanatory power: it means “long context plus heavy generation” scales multiplicatively, and the output-side weight is exactly what most users underestimate.

    4. Tier Value: Replacing Advertised Multipliers with Measured Ones

    Take the entry tier as the baseline, with its short-window quota and long-term cap known. Data measured with the reverse-engineering method above shows a counterintuitive result for the mid-tier upgrade package: its actual short-window quota is about 6x the baseline, and its long-term cap is more than 8x the baseline, both higher than the multipliers its name implies.

    Three actionable rules follow:

    1. Do not decide based on the multiplier in the name. That number is marketing; the measured ratio is the real cost denominator.
    2. Watch the dual-cap structure. The short-window quota determines whether a burst of work can finish; the long-term cap determines whether the whole month is covered. The smaller of the two is the true capacity.
    3. Marginal value jumps. When a tier’s long-term cap grows superlinearly, that tier is the value inflection point.

    5. Putting the Cost Model into Practice

    Build your own calculation sheet with fields for: tier, short-window quota, long-term cap, measured ratio, price per unit of quota, and personal average monthly consumption. The logic:

    1. price per quota unit = monthly fee / long-term cap
    2. effective monthly capacity = min(short-window quota * window count, long-term cap)
    3. recommended tier = the lowest tier where effective monthly capacity >= 1.3 * personal average monthly consumption

    The 30% headroom absorbs month-end submission spikes, ad hoc refactors, and similar variance.

    6. Quota Scheduling: Multiple Accounts and Gateway-Side Governance

    When one person’s demand exceeds a single account’s cap, a common approach is to deploy a protocol gateway locally or in a private environment, aggregate several self-owned accounts behind one entry point, and add weighted round-robin, retry on failure, and quota-aware routing. Engineering points:

    • Quota awareness: route requests preferentially to the account with the most remaining quota, avoiding single-point exhaustion.
    • Idempotency and retries: write operations need an idempotency key to prevent duplicate billing from retries.
    • Observability: record a consumption curve per account, wire it into a logging service and monitoring with alerting, and set threshold notifications.
    • Compliance first: only aggregate accounts you or your team legally hold, follow the terms of service, and avoid sharing or reselling.

    7. The Enterprise View: From Saving Money to Staying in Control

    For enterprise users, real cost optimization is not about unit price but about structure:

    • Tiered routing: push lightweight tasks down to small models; reserve strong models for complex reasoning.
    • Context governance: trim redundant history and enable summary compression to cut the input-side base directly.
    • Cache reuse: cache repeated prompts and retrieval results to reduce duplicate consumption.
    • Unified gateway: deploy alongside a container platform and use object storage for session artifacts, enabling centralized quota control and auditing.

    In general practice on cloud platforms such as Baidu AI Cloud, these capabilities are typically delivered by a combination of gateway services, logging services, monitoring and alerting, and container platforms, without depending on any single tool.

    8. Conclusion

    One unrounded float is enough to make a billing system transparent. For individuals, the method is: reverse-engineer the quota, compute the unit price, leave headroom, then pick a tier. For teams, the focus is tiered routing plus context governance plus centralized quota observability. Understanding the metering model beats chasing discounts for sustained cost reduction.