EN ▾
Get API key

API Rate Limit Reached: What the 429 Means and the Fix

When you see api rate limit reached, the server is returning HTTP 429 because you sent too many requests per minute or too many at once. The fix depends on which of the two it is, and the error code tells you.

Updated

Glowing packets queued at a narrow gate on a conveyor, representing API requests held back by a rate limit

Key points

  1. HTTP 429 with code rate_limited means too many requests per minute
  2. HTTP 429 with code concurrency means too many requests running at the same time
  3. A 429 with a Retry-After: 5 header is temporary overload: wait and retry
  4. Full key: 300 per minute and 8 concurrent; trial key: 60 per minute and 2 concurrent

Read the error before you change anything

The message api rate limit reached is a human label for HTTP status 429. On this API, the response body carries an error code that says exactly which limit you crossed, and that decides what you should do. There are three cases.

What you seeMeaningFix
429, code rate_limitedToo many requests in the last minuteSlow down; spread requests over time
429, code concurrencyToo many requests in flight at onceLower parallelism; wait for calls to finish
429 with Retry-After: 5Temporary overload on the service sideWait 5 seconds, then retry

The first two are about your traffic. The third is not your fault and usually clears by itself. A common mistake is to treat all three the same, for example by adding more workers when the real problem is that you already have too many. Log the code and the headers on every 429, and the pattern becomes obvious within a few minutes.

The limits in numbers

Two kinds of key exist, and the gap between them explains many surprises. A script that works fine on a full key can fail the moment someone runs it with a trial key.

KeyRequests per minuteConcurrent requests
Full key3008
Trial key602

It helps to convert these into rates. 300 per minute is 5 requests per second on average. 60 per minute is one per second. If your loop sends requests as fast as it can without waiting, it will exceed both limits within seconds, because a fast loop fires a burst far above the average.

The maximum request body is 8 MB. Each response includes X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency. The last two tell you the ceilings that apply to your key, so you can read them at startup and size your worker pool from real values instead of hardcoding numbers.

Why concurrency errors surprise people

The per-minute limit is easy to understand. The concurrency limit trips people up, because it counts requests that are still running, not requests that were sent. A long generation can last many seconds, and every second it runs, it holds one of your slots.

Streaming makes this more visible. A streamed request occupies its concurrency slot until the stream ends. If your client opens a stream and then leaves it unread, for example a browser tab closed without cancelling, the slot stays busy until the stream is done. With 8 slots, eight slow streams are enough to block the ninth request, even if you are nowhere near 300 requests a minute.

The practical rule: your worker pool size should never exceed the concurrency ceiling. If you have 8 slots, run at most 8 workers, and leave room if the same key is used from more than one place. A key shared between a web app, a cron job and a teammate's notebook shares one budget.

Retry code that behaves

The right way to handle a 429 is to wait and try again, with growing delays and a hard cap on attempts. The example below turns off the SDK's own retries, so the logic stays in one place, and reads the Retry-After header when it exists.

import random
import time

from openai import OpenAI, RateLimitError

client = OpenAI(
    base_url="https://api.voxtral.top/v1",
    api_key="YOUR_API_KEY",
    max_retries=0,
)

def ask(messages, attempts=6):
    delay = 1.0
    for n in range(attempts):
        try:
            resp = client.chat.completions.create(
                model="uncensored",
                messages=messages,
                max_tokens=400,
            )
            return resp.choices[0].message.content
        except RateLimitError as e:
            if n == attempts - 1:
                raise
            header = e.response.headers.get("Retry-After")
            wait = float(header) if header else delay
            wait += random.uniform(0, 0.5)
            print("429", getattr(e, "code", None), "waiting", round(wait, 1), "s")
            time.sleep(wait)
            delay = min(delay * 2, 30)

Three details matter here. Random jitter stops many workers from retrying at the same instant. The cap of 30 seconds keeps a stuck job from sleeping for minutes. And the attempt limit makes sure a real problem, such as a bug that floods the API, surfaces as an exception rather than an endless loop.

Keep concurrency under the ceiling

Retrying fixes symptoms. For batch work, prevent the errors instead by limiting how many calls run at once. A semaphore does this in a few lines.

import asyncio
from openai import AsyncOpenAI

client = AsyncOpenAI(
    base_url="https://api.voxtral.top/v1",
    api_key="YOUR_API_KEY",
)

LIMIT = asyncio.Semaphore(6)   # stay below the 8 concurrent ceiling

async def one(prompt):
    async with LIMIT:
        r = await client.chat.completions.create(
            model="uncensored",
            messages=[{"role": "user", "content": prompt}],
            max_tokens=300,
        )
        return r.choices[0].message.content

async def main(prompts):
    return await asyncio.gather(*(one(p) for p in prompts))

Six slots instead of eight leaves headroom for retries and for anything else that uses the key. If you are on a trial key, set the semaphore to 1 or 2. The per-minute limit still applies on top, so for large batches add a short pause between launches: 250 milliseconds between starts keeps you near 240 per minute, comfortably under 300.

Batch jobs and pacing

Suppose you need to process 3,000 documents on a full key. At 300 requests per minute the floor is 10 minutes, and in practice it takes longer, since each call also takes time to generate. Plan for the slower of two bounds: the rate limit, and the concurrency limit divided by the average call time. With 8 slots and calls that take 10 seconds each, you complete about 48 requests per minute, far below 300. In that case concurrency is the real ceiling and extra retry logic will not help; only shorter outputs or more patience will.

Shorter outputs are easy to get. Set max_tokens to what the task needs and use stop sequences. Since output is billed at $0.50 per 1M tokens against $0.15 for input, shorter replies are also cheaper. A failed request that returns a 429 is not charged, so retries do not cost you anything extra.

Things not to do

  • Do not retry instantly in a tight loop. It makes the problem worse.
  • Do not create a new client per request in a way that bypasses your own queue.
  • Do not retry 4xx errors other than 429. A malformed request will fail the same way each time.

Checking your limits from the command line

Before you tune any code, look at what the server actually sends back. A single curl call with the response headers shown tells you the ceilings for your key and your balance.

curl -i https://api.voxtral.top/v1/chat/completions   -H "Authorization: Bearer YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{"model":"uncensored","messages":[{"role":"user","content":"ping"}],"max_tokens":5}'

In the output, find X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency. If they read 60 and 2, you are on a trial key, which explains most "it worked yesterday on my other key" reports. If they read 300 and 8, you have a full key and the problem is traffic shape, not the account. The same -i flag shows a Retry-After header on an overload response, and the X-Request-Id you may need for support.

Keep this check in your deployment notes. When a colleague reports rate limit errors, the first question should be which key they used, and the headers answer it in one command. Teams often discover that a staging environment still uses the trial key from the first day of the project, and that the fix is simply to swap in the full key.

One more habit is worth adding: log the status code, the error code and the time for every 429 your application sees. After a day you can plot them. A cluster at the top of each minute points to a cron job that fires everything at once; a steady trickle points to too many workers; a block at a single time of day points to a batch job that someone scheduled without telling the rest of the team.

When it still does not work

If you stay well under both limits and still get 429 with Retry-After: 5 for a long stretch, that is the service reporting overload. Keep your backoff in place, reduce your own parallelism for a while, and try again. If it persists, send the X-Request-Id from a failing response to the support page, with the time and your key type. That value lets the team find the request.

If you simply need more room than a trial key gives, a full key lifts you to 300 requests per minute and 8 concurrent. The API key page explains how to claim the trial and how to top up, and the pricing page lists amounts from $20 to $500. For request and response details, see the docs.

Questions and answers

What does api rate limit reached mean?

The server returned HTTP 429 because your traffic crossed a limit. On this API the error code is rate_limited for too many requests per minute or concurrency for too many at once.

How long should I wait before retrying?

If a Retry-After header is present, such as Retry-After: 5, wait that long. Otherwise start at about one second and double the delay on each attempt, with some random jitter.

Why do I hit the limit with only a few requests?

A trial key allows only 2 concurrent requests and 60 per minute. Streaming also holds a slot until the stream ends, so a few long streams can use up the concurrency allowance.

Am I charged for requests that return 429?

No. Failed or refused requests are not charged.

How can I see my limits in code?

Read the X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency response headers. They show the ceilings for the key you are using.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key