Nebul Docs

Rate Limits & Scaling

How Nebul Inference API rate limits work, the headers returned, and how to handle 429 responses gracefully

Understand how rate limiting works and how to handle limits gracefully.

Overview

The Nebul Inference API applies rate limits to ensure fair usage and platform stability. Limits are applied per API key and vary based on your account tier.

When you exceed your rate limit, the API returns an HTTP 429 Too Many Requests response.


Rate Limit Headers

Every inference response includes TPM (tokens per minute) headers:

HeaderDescription
x-ratelimit-limit-tokensToken limit at the level that governs the request.
x-ratelimit-remaining-tokensTokens left at that level. It reports 0 when the bucket is over-consumed, never a negative.
x-ratelimit-reset-tokensTime until that bucket refills to its limit, for example 30s or 1m6s.
X-TPM-Governing-LevelOn allowed responses, the level governing the request: org, org_model, project, or api_key.

On a 429 caused by a TPM limit, two more headers are present:

HeaderDescription
Retry-AfterThe minimum whole seconds to wait until one token is available at the blocking level.
X-TPM-Block-LevelThe TPM level that blocked the request: org, org_model, project, or api_key.

Limits use a token bucket, not a fixed minute window. Tokens refill continuously, so a reset is the time until that bucket is full again. After heavy usage (over-consumption under high concurrency) it can exceed one minute. The values are a snapshot from the moment the gateway checks the limit, not a reservation for your request.

A 429 can also come from a spent monthly budget instead of a TPM limit. That response carries no Retry-After, because retrying won't fix an exhausted budget. Check the monthly limit in the Studio dashboard.

Every response also includes an x-request-id header for tracing. See Request IDs.


Handling 429 Responses

When you hit a rate limit, implement exponential backoff:

import time
from openai import OpenAI, RateLimitError
import os

client = OpenAI(
    api_key=os.environ["NEBUL_API_KEY"],
    base_url="https://api.inference.nebul.io/v1"
)

def make_request_with_retry(messages, max_retries=5):
    for attempt in range(max_retries):
        try:
            return client.chat.completions.create(
                model="zai-org/GLM-5.3",
                messages=messages
            )
        except RateLimitError as e:
            if attempt == max_retries - 1:
                raise
            wait_time = (2 ** attempt) + 1  # Exponential backoff
            print(f"Rate limited. Waiting {wait_time}s...")
            time.sleep(wait_time)

Checking Your Limits

Your current rate limits and usage are visible in your Nebul AI Studio dashboard under the API section. Here you can:

  • View your current tier and associated limits
  • Monitor real-time usage against your quotas
  • Request limit increases if needed

Best Practices

  1. Monitor headers: Track x-ratelimit-remaining-* headers to stay under limits
  2. Implement backoff: Always use exponential backoff when retrying after 429s
  3. Batch requests: Combine multiple prompts where possible to reduce request count
  4. Cache responses: Cache identical requests to avoid redundant API calls
  5. Use streaming: For long responses, streaming doesn't change token limits but improves perceived latency

Need Higher Limits?

If you consistently hit rate limits, you can:

  1. Check your tier: Upgrade your account tier in AI Studio for higher limits
  2. Contact us: Reach out for custom enterprise limits tailored to your workload

On this page