Usage limits let you set a maximum number of requests a key can make. After the limit is reached, the key becomes invalid until you add more credits or reset it. This is different from rate limiting, which controls frequency, usage limits control total volume.Documentation Index
Fetch the complete documentation index at: https://unkey.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
When to use this
Pay-per-use APIs
Sell API credits that get consumed with each request. Customer buys 10,000
requests, key stops working at 10,001.
Trial/freemium tiers
Give new users 100 free requests to try your API. They upgrade or stop.
Subscription quotas
“Pro plan includes 50,000 requests/month”, combine with
auto-refill for recurring limits.
One-time tokens
Create a key that works exactly once, like a single-use download link.
How it works
- Create a key with
credits.remainingset to your limit - Each verification decrements the remaining count
- When remaining hits 0, verification fails with
code: USAGE_EXCEEDED - You can add more credits anytime via the API
Create a key with usage limits
Verification response
When you verify a key with usage limits, the response includes the current credit count:The
credits value shows remaining credits after this verification. A
value of 999 means the key can be verified 999 more times.Custom cost per request
By default, each verification costs 1 credit. But some operations should cost more, maybe a complex query costs 10 credits while a simple lookup costs 1. Specify the cost at verification time:Cost of 0 (check without consuming)
Setcost: 0 to verify a key without consuming any credits. Useful for checking key validity or metadata without affecting the balance.
Add more credits
When a user purchases more credits or you need to refill manually:set, Set credits to an exact valueincrement, Add credits to current balancedecrement, Subtract credits from current balance
Remove usage limits
To make a key unlimited again, set credits tonull:
Usage limits vs rate limits
| Feature | Usage Limits | Rate Limits |
|---|---|---|
| What it controls | Total requests ever | Requests per time window |
| Resets automatically? | No (unless using refill) | Yes, after window expires |
| Use case | Billing, quotas, trials | Abuse protection, fair usage |
| Example | ”1000 requests total" | "100 requests per minute” |
Next steps
Auto-refill
Automatically reset credits on a schedule (daily, monthly)
Rate limiting
Control request frequency, not just total volume

