EN ▾
Start with free creditsUse email and password; your key appears instantly.

Uncensored OpenAI-Compatible API

Create key

OpenRouter Rate Limit Reset: When Can You Retry?

The openrouter rate limit reset depends on which kind of limit you hit: a short rolling window clears in seconds to a minute, while a daily cap waits for its own schedule. The reliable signal is the Retry-After header, and a client that reads it never has to guess.

Last updated

Hourglass whose sand becomes data packets queuing at gates, a picture of waiting for a rate limit to reset

When does the limit reset

There is no single reset time, because a rate limit is really three different things sharing one status code. Per-minute limits recover as the window moves on, so a short pause usually fixes them. Concurrency limits recover the moment one of your in-flight requests finishes. Daily or credit-based caps recover on a schedule the provider controls. For the exact windows on OpenRouter, read its current documentation, since the numbers belong to that service and may change.

The part you control is the client. A client that reads the server's own hint and waits accordingly will behave correctly under any of the three, which is why most of this article is about code rather than clock times.

Three kinds of reset, and how each behaves

Per-minute windows

A requests-per-minute limit counts calls over a window. Implementations differ: some use a fixed minute that resets on the clock, others a sliding window. In both cases, pausing for a few seconds and retrying is the right first move, and a repeat failure means you are still sending too fast on average.

Concurrency limits

These count requests in flight, not requests per time. There is no timer to wait out. A slot frees when a response completes, so the fix is to hold back new work until something finishes. Streaming makes this subtle, because a stream keeps its slot open until the last chunk.

Daily and balance caps

A cap that resets once a day, or that depends on account credit, will not clear with a retry in a minute. If the same call keeps failing for hours, stop retrying, tell the user, and either wait for the reset or change how the account is funded. Hammering it only fills your logs.

Read Retry-After before you guess

Retry-After is a standard HTTP header. Its value is either a number of seconds or an HTTP date. Servers use it to say exactly how long to hold off, and a client that honours it recovers faster than one that guesses and wastes fewer calls.

On our endpoint, a temporary overload returns HTTP 429 with Retry-After: 5. Exceeding the per-minute limit returns 429 with the code rate_limited, and too many parallel requests returns 429 with the code concurrency. Those two codes tell you which timer you are dealing with: wait out the minute for the first, wait for a free slot for the second.

The ceilings themselves are in the response headers X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency. They tell you the maximum, not how much is left, so a well-behaved client keeps its own counter rather than waiting for the server to say no.

Client code that waits the right amount

This Python version parses both forms of Retry-After, falls back to exponential backoff when the header is absent, and adds up to a second of jitter so parallel workers do not wake together.

import email.utils
import random
import time

import requests

URL = "https://api.openrouterratelimits.com/v1/chat/completions"
HEADERS = {"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"}

def parse_retry_after(value):
    """Return seconds to wait, or None if the header is missing or unusable."""
    if not value:
        return None
    if value.strip().isdigit():
        return float(value)
    try:                                   # HTTP-date form
        when = email.utils.parsedate_to_datetime(value)
        return max(0.0, when.timestamp() - time.time())
    except (TypeError, ValueError):
        return None

def post_with_wait(payload, attempts=6):
    backoff = 1.0
    for attempt in range(attempts):
        r = requests.post(URL, headers=HEADERS, json=payload, timeout=120)
        if r.status_code != 429:
            r.raise_for_status()
            return r.json()
        wait = parse_retry_after(r.headers.get("Retry-After"))
        if wait is None:
            wait = backoff
            backoff = min(backoff * 2, 30)
        wait += random.uniform(0, 1)
        print(f"429 ({attempt + 1}/{attempts}), sleeping {wait:.1f}s")
        time.sleep(wait)
    raise RuntimeError("still rate limited after retries")

data = post_with_wait({
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Say hello in five words."}],
    "max_tokens": 20,
})
print(data["choices"][0]["message"]["content"])

The same logic in Node, using the built-in fetch:

const BASE = "https://api.openrouterratelimits.com/v1";

const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

async function chat(messages, attempts = 6) {
  let backoff = 1000;
  for (let i = 0; i < attempts; i++) {
    const res = await fetch(`${BASE}/chat/completions`, {
      method: "POST",
      headers: {
        Authorization: "Bearer YOUR_KEY",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ model: "uncensored", messages, max_tokens: 50 }),
    });
    if (res.status !== 429) {
      if (!res.ok) throw new Error(`HTTP ${res.status}`);
      return res.json();
    }
    const header = Number(res.headers.get("retry-after"));
    const wait = Number.isFinite(header) && header > 0 ? header * 1000 : backoff;
    backoff = Math.min(backoff * 2, 30000);
    await sleep(wait + Math.random() * 500);
  }
  throw new Error("still rate limited after retries");
}

chat([{ role: "user", content: "Name three colours." }]).then((d) =>
  console.log(d.choices[0].message.content)
);

Both versions stop after six attempts. Past that point the sensible response is to queue the job for later or report the failure, not to keep sleeping inside a request handler.

Keep a local counter so you rarely hit a reset at all

A reset is something you only wait for after you have gone over. A small token-bucket in front of your client avoids most of those waits. Pick a rate a little under the documented ceiling, release requests at that pace, and let bursts queue.

For a full key on our API the ceiling is 300 requests per minute and 8 concurrent, which works out to 5 requests per second on average. Pacing at 4 per second with at most 6 in flight leaves room for overload spikes. A trial key allows 60 per minute and 2 concurrent, so pace it at 1 per second with 1 or 2 in flight.

If your traffic is bursty because of user behaviour, such as many people pressing a button right after an announcement, put a queue between your app and the API. Users wait a second or two for their turn instead of seeing an error.

Test your waiting code before production does

Rate-limit handling is the kind of code that works in every demo and fails in the first real spike. You can test it without hitting a real provider by running a local stub that returns 429 a few times and then succeeds. Point your client at the stub's address and check the timing.

A good test list is short:

  1. The stub returns 429 with Retry-After: 2 once. Assert that the client waited at least two seconds, and no more than about three.
  2. The stub returns 429 with no header three times. Assert that the delays grow roughly as 1, 2 and 4 seconds, plus jitter.
  3. The stub returns 429 six times in a row. Assert that the client raises an error instead of sleeping forever.
  4. The stub returns 400. Assert that the client does not retry.
  5. The stub returns an HTTP-date Retry-After in the past. Assert that the client treats it as zero and does not crash.

Inject the sleep function so tests run instantly: pass time.sleep as a parameter by default, and swap in a recorder in the test that stores the requested delays. Then you can assert on the numbers without waiting.

What to do when the wait is long

If a server asks for a delay of several minutes, a request handler should not sit and sleep. Put the job in a durable queue with a not-before timestamp, return an acknowledgement to the user, and let a worker pick it up when the time comes. For interactive features, show that the request is queued and give an honest estimate. A worker that sleeps for ten minutes inside a web request will be killed by a proxy timeout long before the reset.

Finally, keep one switch you can flip in production to lower your sending rate, such as an environment variable for the concurrency cap. During an incident you want to change one number, not ship a release.

What a failed request costs

A limited request that never ran does no work, and on our API failed or refused requests are not charged. Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens from prepaid credit, and credit never expires. You can see the remaining balance in the X-Balance-USD header on any response. Details are on the pricing page, and the docs list every endpoint. To try the retry code with a real key, claim the $0.50 trial on the API key page.

If you are comparing routers with direct endpoints more broadly, OpenRouter api: myths vs facts goes through the common assumptions.

FAQ

How long until an OpenRouter rate limit resets?

It depends on the limit type. Per-minute and concurrency limits recover quickly, daily caps follow a schedule. Check OpenRouter's current documentation and honour any Retry-After header.

What does Retry-After: 5 mean?

The server is asking you to wait five seconds before sending the request again. On our API this header accompanies a 429 caused by temporary overload.

Does a retry count against my limit?

Yes, a request that reaches the server usually counts toward the per-minute total, so retrying instantly in a loop makes the problem worse.

Can I see how many requests I have left?

Our responses show your ceilings in X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency, not a countdown, so keep a local counter.

Get your key in seconds

Register, copy your key, and update the base URL. That is all.