Usage quotas are longer-horizon ceilings—daily/monthly tokens, dollars, or requests—beyond per-minute rate limits. They are how orgs enforce budgets as product policy.
Pairs with spend alerts next; quotas are the hard stop, alerts are the early warning.
Related foundations: recount tokens with tiktoken (Vol. 12) and keep payloads inside the context window (Vol. 11).
Learning Objectives
By the end of this lesson, students should be able to:
- Distinguish quotas from rate limits.
- Set quotas in tokens and/or USD.
- Implement soft vs hard quota behaviors.
- Scope quotas by org, project, and API key.
- Reset and carry-over policies intentionally.
- Expose remaining quota to developers/users.
Usage quotas are maximum allowed consumption over a billing or calendar period (tokens, requests, or dollars), enforced independently of short-term rate limits.
| Scope | Example | Owner |
|---|---|---|
| Account | Provider monthly cap | Cloud admin |
| Project | $5k LLM COGS / mo | Eng + finance |
| API key / env | Staging 2M tokens/day | Platform |
| End customer | Plan tier allowance | Product |
Code: Soft then Hard Quota
Rate limit
- Per minute/second
- Smooths bursts
- Resets quickly
Quota
- Per day/month
- Enforces budget
- Resets on schedule
Both
- Needed together
- Different UX errors
- Different dashboards
Strengths
- Predictable maximum spend
- Multi-tenant fairness
- Clear upgrade paths
Tradeoffs
- Hard blocks anger users if opaque
- Token vs $ quotas diverge with price changes
- Reset cliffs cause rushes
“RPM limits already protect our monthly budget.” A low RPM sustained 24/7 can still exhaust monthly dollars. Quotas close that gap.
Knowledge Check
- Short Answer: How do quotas differ from rate limits? Answer: Quotas are period budgets; rate limits are short-term throughput caps.
- True/False: Quotas can be denominated in USD. Answer: True.
- Multiple Choice: Soft quota typically: (a) warns, (b) formats disks, (c) changes embeddings. Answer: (a).
- Short Answer: Name a quota scope. Answer: Account, project, API key, or customer plan.
- True/False: Sustained low RPM cannot blow a monthly budget. Answer: False.
- Multiple Choice: Staging keys often need: (a) infinite quota, (b) tight quotas, (c) no logging. Answer: (b).
- Short Answer: Why expose remaining quota? Answer: So clients can shed load or upgrade before hard block.
- Short Answer: What meter from 13.3 feeds token quotas? Answer: Input/output token usage counts.
- Multiple Choice: Hard block should return: (a) silent success, (b) clear error/upgrade path, (c) random 200. Answer: (b).
- True/False: Price changes can desync token quotas from dollar budgets. Answer: True.
Key Takeaways
- Quotas enforce period budgets; RPM does not.
- Prefer soft warn then hard block.
- Scope by project and customer tier.
- Show remaining quota in APIs/UI.
- Next: Spend Alerts & Budgets.
Lab: Design quota tiers for free/pro/enterprise; define soft% and hard actions.
Discussion: Token quota vs dollar quota—which for a multi-model gateway?
Recap: Quotas are the monthly walls around token spend. Continue with Spend Alerts & Budgets.