Daily token quota planner
A handful of heavy users can quietly consume most of your API budget. The fix is per-user token quotas: a fair daily allowance that keeps total spend predictable. This planner takes your daily budget, user counts and a blended token price, and computes the daily token quota for free and paid users — with paid users getting a configurable multiple of the free allowance.
How it works
The planner converts your daily budget into a total token allowance, then splits
it across users weighted by tier. Paid users get ratio× the free quota:
total_tokens = (daily_budget / blended_price) × 1,000,000
weight_sum = free_users × 1 + paid_users × ratio
free_quota = total_tokens / weight_sum
paid_quota = free_quota × ratio
This guarantees that if every user spends exactly their quota, you land on budget — no surprises.
Worked example
Say your daily budget is $20, you have 500 free users and 50 paid users, your blended token price is $2.00 per million, and you want paid users to receive 5× the free quota.
- Total tokens available: ($20 / $2.00) × 1,000,000 = 10,000,000 tokens
- Weight sum: 500 × 1 + 50 × 5 = 750
- Free quota: 10,000,000 / 750 ≈ 13,333 tokens/day
- Paid quota: 13,333 × 5 ≈ 66,667 tokens/day
At those quotas, even if every free user maxes out (500 × 13,333 = 6.67M) and every paid user maxes out (50 × 66,667 = 3.33M) the total is exactly $20 — the math is guaranteed to balance when the ratio is applied consistently.
What to do when usage is uneven
In practice, heavy users consume far more than the average. A useful heuristic is to treat your active user count as only the top 20% of registered users when sizing quotas — that way you build in headroom for the power users without over-provisioning for the majority who barely touch the API.
Enforcement and upgrade signals
This tool sizes the numbers; enforcing the quota lives in your rate-limiting layer (Redis counters keyed by user ID, reset on a rolling 24-hour window work well). When a free user hits their cap, surface an upgrade prompt immediately — a user who repeatedly maxes out their free allowance is your warmest paid-conversion signal. Rolling resets (rather than midnight UTC) spread the reset load and avoid a thundering herd at the top of each hour.
Tips
- Set quotas slightly below the exact budget figure to leave headroom for bursts and for the share of users who exceed the average.
- Blended price accuracy matters: estimate it from your observed input-to-output token ratio multiplied by the respective per-million prices for your model.
- If paid users are a tiny fraction of your base, consider raising the ratio rather than lowering the free quota — it rewards paying customers without penalising the free tier heavily.