Rate Limits
Understand and manage API rate limits to optimize your application's performance.
Rate Limit Tiers
| Tier | Monthly Requests | Per-Minute Limit | Price |
|---|---|---|---|
Free | 1,000 | 10 | $0 |
Starter | 25,000 | 60 | $19/month |
Growth | 150,000 | 120 | $79/month |
Business | 500,000 | 300 | $249/month |
How limits are counted: The per-minute limit is a sliding 60-second window applied per API key. There is no separate burst allowance. The native and Perspective-compatible endpoints share the same per-key window.
Monthly requests count successful moderation calls (one per request, whatever the categories, themes, or consensus setting). They reset on the 1st of each calendar month (UTC). Status checks (GET /v1/moderate) and Perspective comments:suggestscore don't count. Requests rejected for a bad body or bad key don't count toward either limit.
Rate Limit Headers
Successful moderation responses (and 429 rate-limit responses) include headers to help you monitor your rate limit status:
HTTP/1.1 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1760193060000
Content-Type: application/json
{
"request_id": "mod_3f2b8c1e-9a4d-4c7e-b1f0-6d2a5e8c9b13",
"flagged": false,
...
}Your per-minute request limit for current tier
Requests remaining in current minute window
Unix timestamp in milliseconds when the window resets
Seconds to wait before retrying. Only sent on 429 responses.
Handling Rate Limits
429 Too Many Requests
When you exceed your rate limit, the API returns a 429 status code with a Retry-After header indicating how many seconds to wait before making another request. Perspective-compatible endpoints return a Google-style RESOURCE_EXHAUSTED error without these headers.
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 10
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1760193060000
Retry-After: 23
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please try again later."
},
"request_id": "mod_8d0c6f2a-41b7-4e59-9c3d-2a7e1f5b6c04"
}402 Payment Required (monthly quota)
Once the monthly limit is used up, /v1/moderate/text returns 402 quota_exceeded until the next calendar month or until you upgrade. Retrying won't help. (Perspective-compatible endpoints return 429 RESOURCE_EXHAUSTED with reason quotaExceeded instead.)
HTTP/1.1 402 Payment Required
{
"error": {
"code": "quota_exceeded",
"message": "Monthly usage limit exceeded. Please upgrade your plan or wait for the next billing period.",
"details": {
"usage": 1000,
"limit": 1000
}
},
"request_id": "mod_c41e9b7d-2f0a-4d6b-8e35-7a19f0c2d6e8"
}✅ Best Practices
- • Implement exponential backoff
- • Monitor rate limit headers
- • Use request queues for high volume
- • Respect Retry-After headers
- • Cache responses when possible
💡 Optimization Tips
- • Spread requests evenly
- • Moderate in a background job for non-interactive content
- • Monitor usage patterns
- • Consider higher tiers for growth
❌ What to Avoid
- • Immediate retries after 429
- • Ignoring rate limit headers
- • Burst traffic without queuing
- • Not handling 429 errors
- • Aggressive retry strategies
Implementation Examples
Exponential Backoff
// JavaScript - Exponential backoff implementation
class RateLimitHandler {
constructor(baseDelay = 1000, maxDelay = 32000, maxRetries = 5) {
this.baseDelay = baseDelay;
this.maxDelay = maxDelay;
this.maxRetries = maxRetries;
}
async makeRequest(requestFn) {
for (let attempt = 0; ; attempt++) {
const response = await requestFn();
// Check rate limit headers
const remaining = response.headers.get('X-RateLimit-Remaining');
if (remaining && parseInt(remaining, 10) < 5) {
console.warn('Approaching rate limit. Consider slowing down requests.');
}
// fetch() doesn't throw on HTTP errors, so check the status
if (response.status !== 429 || attempt >= this.maxRetries - 1) {
return response;
}
// Use Retry-After (seconds) when present, otherwise back off exponentially
const retryAfter = parseInt(response.headers.get('Retry-After') ?? '', 10);
const delay = retryAfter > 0
? retryAfter * 1000
: Math.min(this.baseDelay * Math.pow(2, attempt), this.maxDelay);
console.log(`Rate limited. Waiting ${delay}ms before retry ${attempt + 1}`);
await this.sleep(delay);
}
}
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
// Usage
const rateLimiter = new RateLimitHandler();
const response = await rateLimiter.makeRequest(() =>
fetch('https://api.moder8r.app/v1/moderate/text', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.MODER8R_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: 'Text to moderate' })
})
);Request Queue for High Volume
// Request queue for high-throughput applications
class RequestQueue {
constructor(requestsPerMinute = 60) {
this.requestsPerMinute = requestsPerMinute;
this.requestTimes = [];
this.queue = [];
this.processing = false;
}
async addRequest(requestFn) {
return new Promise((resolve, reject) => {
this.queue.push({ requestFn, resolve, reject });
this.processQueue();
});
}
async processQueue() {
if (this.processing || this.queue.length === 0) {
return;
}
this.processing = true;
while (this.queue.length > 0) {
const now = Date.now();
// Remove requests older than 1 minute
this.requestTimes = this.requestTimes.filter(time => now - time < 60000);
// Check if we can make another request
if (this.requestTimes.length >= this.requestsPerMinute) {
const oldestRequest = Math.min(...this.requestTimes);
const waitTime = 60000 - (now - oldestRequest);
console.log(`Rate limit reached. Waiting ${waitTime}ms`);
await this.sleep(waitTime);
continue;
}
// Process next request
const { requestFn, resolve, reject } = this.queue.shift();
try {
this.requestTimes.push(now);
const result = await requestFn();
resolve(result);
} catch (error) {
reject(error);
}
// Small delay between requests to avoid overwhelming the server
await this.sleep(100);
}
this.processing = false;
}
sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}Monitoring and Scaling
Usage Monitoring
- • Track request patterns over time
- • Set alerts at 80% of monthly quota
- • Monitor error rates and 429 responses
- • Analyze peak usage periods
- • Read the
usageblock on each response, or callGET /v1/moderate
When to Upgrade
- • Consistently hitting monthly limits
- • Frequent 429 errors during normal operation
- • Planning for traffic growth
- • Requiring better SLA guarantees
Pro tip: Consider upgrading before you hit limits rather than after. This ensures consistent performance for your users and prevents unexpected service disruptions.