Docs
Rate Limits
Rate Limits
Configure and understand rate limits for your virtual keys.
Rate limits control how many API requests can be made per key within a time window. They help prevent abuse, manage costs, and ensure fair usage.
Understanding Rate Limits
What Gets Limited
| Metric | Description |
|---|---|
| Requests/minute | Total API calls per minute |
| Tokens/minute | Total tokens processed per minute |
| Tokens/day | Daily token limit |
How Limits Work
- Each key has configured limits
- Requests count against the limit
- Limits reset at the end of each period
- Exceeding limits returns 429 errors
Default Limits by Plan
| Plan | Requests/min | Tokens/min | Tokens/day |
|---|---|---|---|
| Free | 20 | 40,000 | 200,000 |
| Standard | 100 | 200,000 | 2,000,000 |
| Premium | 500 | 1,000,000 | 10,000,000 |
| Enterprise | Custom | Custom | Custom |
Configuring Limits
Per-Key Limits
Set limits when creating or editing a key:
- Go to Settings > API Keys
- Click on a key to edit
- Adjust rate limit settings
- Save changes
Available Settings
| Setting | Description |
|---|---|
| Requests per minute | Max API calls per minute |
| Max budget | Monthly spending cap |
| Model restrictions | Limit to specific models |
Rate Limit Headers
API responses include rate limit information:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1234567890
| Header | Description |
|---|---|
| X-RateLimit-Limit | Your limit for this period |
| X-RateLimit-Remaining | Requests remaining |
| X-RateLimit-Reset | Unix timestamp when limit resets |
Handling Rate Limits
429 Response
When you exceed limits:
{
"error": {
"message": "Rate limit exceeded. Please slow down.",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}Implementing Backoff
import time
import random
def request_with_backoff(make_request, max_retries=5):
for attempt in range(max_retries):
try:
return make_request()
except RateLimitError as e:
if attempt < max_retries - 1:
# Exponential backoff with jitter
wait = (2 ** attempt) + random.uniform(0, 1)
time.sleep(wait)
else:
raiseBest Practices
- Check headers: Monitor remaining quota
- Implement backoff: Handle 429s gracefully
- Queue requests: Smooth out traffic spikes
- Use batching: Combine requests where possible
Monitoring Usage
In Studio
View rate limit usage:
- Go to Analytics > Usage
- Select your key
- View requests over time
- Check for rate limit events
Alerts
Set up alerts for:
- Approaching rate limits (80% threshold)
- Rate limit exceeded events
- Unusual traffic patterns
Optimizing for Limits
Reduce Request Volume
- Cache responses where appropriate
- Batch similar requests
- Use efficient prompts
Reduce Token Usage
- Use concise prompts
- Set appropriate
max_tokens - Choose smaller models for simple tasks
Spread Traffic
- Implement request queuing
- Use multiple keys for different services
- Schedule batch jobs during off-peak times
Upgrading Limits
If you consistently hit limits:
- Review your usage patterns
- Optimize where possible
- Upgrade your plan for higher limits
- Contact support for Enterprise options
Related
- Virtual Keys Overview - Key management
- Creating Keys - Create new keys
- Error Handling - Handle rate limit errors