Rate Limits
Understand the rate limits for the ContextFile API and how to handle them.
Overview
Rate limits protect the API from abuse and ensure fair usage for all users. Limits are applied per API key and vary based on your subscription plan.
Rate limits are per API key
Each API key has its own rate limit counter. Creating multiple keys does not increase your overall rate limit.
Limits by Plan
Free
API rate limits
Per minute10
Per hour100
Per day500
Per month5,000
ProPopular
API rate limits
Per minute60
Per hour1,000
Per day5,000
Per month50,000
Team
API rate limits
Per minute120
Per hour3,000
Per day15,000
Per month150,000
Enterprise
API rate limits
Per minute600
Per hour10,000
Per day100,000
Per month1,000,000
Rate Limit Headers
Every API response includes headers that tell you about your current rate limit status:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed in the current window |
X-RateLimit-Remaining | Number of requests remaining in the current window |
X-RateLimit-Reset | Unix timestamp when the rate limit window resets |
Retry-After | Seconds to wait before retrying (only on 429 responses) |
Example Response Headers
HTTP/1.1 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1704067200Handling Rate Limits
When you exceed the rate limit, you'll receive a 429 Too Many Requests response:
429Rate Limit Exceeded
{
"error": "Too many requests. Please try again later."
}Best Practices
1Implement exponential backoff
When you receive a 429 response, wait and retry with increasing delays.
async function fetchWithRetry(url, options, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
const response = await fetch(url, options);
if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After') || 60;
await new Promise(r => setTimeout(r, retryAfter * 1000 * (i + 1)));
continue;
}
return response;
}
throw new Error('Max retries exceeded');
}2Monitor your usage
Use the rate limit headers to track your usage and avoid hitting limits. Consider implementing client-side rate limiting.
3Cache responses when possible
Reduce API calls by caching responses that don't change frequently.
4Upgrade your plan if needed
If you consistently hit rate limits, consider upgrading to a higher tier.