Rate Limits

To ensure the stability and availability of our API for all users, Meibel AI 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 Limits by Subscription Plan

Free Tier

  • 60 requests per minute
  • 1,000 requests per day
  • Limited streaming duration

Pro Plan

  • 300 requests per minute
  • 10,000 requests per day
  • Extended streaming duration

Enterprise

  • Custom limits
  • Priority during high load
  • Dedicated support

For the most up-to-date information on rate limits for your subscription, check your account dashboard.

Rate Limit Errors

When you exceed your rate limit, the API returns a 429 Too Many Requests error with the following response body:

{
  "error": {
    "message": "Rate limit exceeded: 100 requests per minute. Please retry after 45 seconds.",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "request_id": "req_123456789"
  }
}

Best Practices for Handling Rate Limits

1

Implement backoff and retry logic

When you receive a 429 response, use the X-RateLimit-Reset header to determine when to retry your request. Implement an exponential backoff strategy for retries.

2

Monitor your usage

Keep track of your rate limit usage through the headers in the API responses to ensure you’re staying within your limits.

3

Batch requests when possible

Instead of making multiple small requests, batch operations together when the API supports it.

4

Cache responses

Cache API responses that don’t change frequently to reduce the number of requests you need to make.

Example Retry Implementation

Here’s an example of how to implement retry logic in Python:

import time
import requests
from meibelai import Meibelai
import os

def make_request_with_retry(client, method, *args, max_retries=5, **kwargs):
    retries = 0
    while True:
        try:
            return method(*args, **kwargs)
        except models.APIError as e:
            if e.status_code != 429 or retries >= max_retries:
                raise
            
            # Extract retry-after header or default to exponential backoff
            retry_after = int(e.raw_response.headers.get('Retry-After', 2 ** retries))
            print(f"Rate limited. Retrying after {retry_after} seconds.")
            time.sleep(retry_after)
            retries += 1

# Usage example
client = Meibelai(
    api_key_header=os.getenv("MEIBELAI_API_KEY_HEADER", ""),
)
response = make_request_with_retry(client, client.datasources.list)

Rate Limit Considerations

Streaming Endpoints

Streaming endpoints (like chat and completion streams) have different rate limits based on:

  • Number of requests
  • Duration of streaming connections
  • Amount of data transmitted

Burst Behavior

Our rate limiting system allows for occasional bursts of traffic that exceed your normal limits, but consistent overages will trigger rate limiting.

IP-Based Rate Limiting

In addition to API key-based rate limiting, we also employ IP-based rate limiting as a security measure. This helps protect against unauthorized access attempts.

Increasing Your Rate Limits

If you need higher rate limits:

  1. Upgrade your plan: Consider upgrading to a higher tier subscription
  2. Contact sales: Enterprise customers can request custom rate limits by contacting sales@meibel.ai
  3. Optimize your usage: Review our best practices to ensure efficient API usage

Repeatedly exceeding your rate limits may result in temporary or permanent restrictions on your API key. Always implement proper rate limit handling in production applications.