Skip to main content

When to Use This

You’re running a production integration that:
  • Makes many requests per minute (near or above your tier limit)
  • Uses concurrent workers (background jobs, async handlers)
  • Hits endpoint-specific limits (e.g. Mave max 10 concurrent, Focus Groups max 5)
  • Needs to avoid 429s proactively instead of only reacting with retries
This cookbook covers:
  • Proactive throttling using X-RateLimit-* headers
  • Token bucket style rate limiting to smooth request rate
  • Concurrency limiting (semaphores) for endpoint-specific caps
  • Request queuing when you must process many items without bursting
  • Production checklist and metrics to monitor

Rate Limit Recap

Endpoint-specific concurrency limits: Every response includes:

Pattern 1: Proactive Throttling from Headers

Don’t burst to the limit. After each request, read X-RateLimit-Remaining. If it’s low (e.g. < 10), slow down before you hit 429.

Pattern 2: Token Bucket (Smooth Request Rate)

A token bucket lets you maintain a steady request rate instead of bursting. Refill tokens over time; consume one per request. If no tokens, wait.

Pattern 3: Concurrency Limiting (Semaphore)

For endpoints with max concurrent limits (Mave: 10, Focus Groups: 5, Video: 3), use a semaphore so you never exceed that many in-flight requests.
Combine semaphore with token bucket: semaphore for concurrency, token bucket for overall request rate. E.g. 10 concurrent Mave requests, but only 4 new Mave requests per minute across all workers.

Pattern 4: Request Queue for Batch Processing

When you have a list of items to process (e.g. 500 chat requests), push them into a queue and process at a controlled rate. Prevents spikes and respects limits.

Pattern 5: Exponential Backoff on 429 (Reactive)

When you do get a 429, respect Retry-After and use exponential backoff. Combine with jitter to avoid thundering herd.

Production Checklist

Confirm your rate limit (60/120/240/600 rpm). Design throttling for 80–90% of that to leave headroom.
Mave (10), Focus Groups (5), Video (3). Use semaphores or equivalent.
Log X-RateLimit-Remaining and X-RateLimit-Reset periodically. Alert when remaining < 5 frequently.
Single chat with full conversation history instead of many single-message calls.
Run load tests at 90% of your limit. Verify you get headers and throttle correctly.

Metrics to Monitor


See Also

Rate Limits Guide

Tiers, headers, and basic handling

Error Handling Patterns

Retry logic and backoff

Credits

Credit usage (separate from rate limits)

Contact Sales

Higher limits for Enterprise