Skip to main content
To ensure the stability and availability of our API for all users, Meibel implements rate limiting. This page explains our rate limiting system and how to handle rate limit errors.

Understanding Rate Limits

Rate limits are applied on a per-API-key basis and vary depending on your subscription plan. Rate limits are calculated based on rolling time windows, typically per minute and per day.

Rate Limit Headers

Every API response includes headers that provide information about your current rate limit status:
HeaderDescription
X-RateLimit-LimitThe maximum number of requests allowed in the current time window
X-RateLimit-RemainingThe number of requests remaining in the current time window
X-RateLimit-ResetThe time at which the current rate limit window resets (UTC epoch seconds)
Example headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1620000000

Rate Limit Errors

When you exceed your rate limit, the API returns a 429 Too Many Requests error:
{
  "message": "Rate limit exceeded. Please retry after 45 seconds."
}
The response will include a Retry-After header indicating how many seconds to wait.

Handling Rate Limits

from meibel import MeibelClient
from meibel.exceptions import RateLimitError
import time
import os

client = MeibelClient(api_key=os.getenv("MEIBEL_API_KEY"))

def request_with_retry(fn, *args, max_retries=5, **kwargs):
    for attempt in range(max_retries):
        try:
            return fn(*args, **kwargs)
        except RateLimitError as e:
            if attempt == max_retries - 1:
                raise
            wait = e.retry_after or (2 ** attempt)
            print(f"Rate limited. Retrying in {wait}s...")
            time.sleep(wait)

Best Practices

1

Implement backoff and retry logic

When you receive a 429 response, use the Retry-After header to determine when to retry. Use exponential backoff as a fallback.
2

Monitor your usage

Check rate limit headers in API responses to stay within your limits.
3

Batch requests when possible

Combine operations to reduce the number of requests.
4

Cache responses

Cache API responses that don’t change frequently to reduce request volume.

Increasing Your Rate Limits

If you need higher rate limits:
  1. Contact sales: Enterprise customers can request custom rate limits by contacting sales@meibel.ai
  2. Optimize your usage: Review our best practices to ensure efficient API usage
Repeatedly exceeding your rate limits may result in temporary restrictions on your API key. Always implement proper rate limit handling in production applications.