Skip to content

OpenAI API errors

OpenAI error 429: Rate limit reached

This one is usually on your side: your organization sent more requests or tokens per minute than its usage tier allows, and OpenAI asked it to slow down.

What the error says

HTTP status 429, type rate_limit_exceeded, with the message:

Rate limit reached for requests

Is the OpenAI API down right now?

Our live reading did not load here. The OpenAI outage page has it, with OpenAI's own status beside it.

What it means

OpenAI enforces limits per organization and per model on requests per minute, tokens per minute and, for some models, requests or tokens per day. When a request would pass one of them, the API answers 429 with the type rate_limit_exceeded and a message naming the limit that was reached. The response headers x-ratelimit-remaining-requests, x-ratelimit-remaining-tokens and the matching reset headers say how much is left and when it refills.

Is it you or them? Usually yours: OpenAI uses this code for limits and billing on your account, which no outage checker can see.

Common causes

  • Bursts: many requests at once, for example a batch job or parallel workers, even when the per-minute average is low.
  • Large max_tokens values: OpenAI counts the requested maximum against the token limit before the reply is generated.
  • A low usage tier: new organizations start with small limits that rise with spend and account age.
  • Several apps or environments sharing one organization's limit.

How to fix it

  1. Retry with exponential backoff and jitter, as in the snippet below, and honour the reset headers.
  2. Lower max_tokens to what the reply needs, and spread requests out instead of sending them in bursts.
  3. Use the Batch API for work that does not need an answer right away; it has its own, higher limits.
  4. Check your tier and limits in the organization's limits page; they rise as the account spends more.

Retry with backoff

A retry loop that waits as long as OpenAI asks, else doubles the wait with random jitter so many clients do not retry in step:

// Retry OpenAI 429 errors with backoff and jitter.
const RETRYABLE = new Set([429, 500, 502, 503, 504, 529]);

async function withRetry(call: () => Promise<Response>, maxAttempts = 5): Promise<Response> {
  for (let attempt = 1; ; attempt++) {
    const response = await call();
    if (!RETRYABLE.has(response.status) || attempt === maxAttempts) return response;
    // Wait as long as the provider asks, else 1s, 2s, 4s... with full jitter.
    const retryAfter = Number(response.headers.get("retry-after"));
    const delayMs = retryAfter > 0 ? retryAfter * 1000 : Math.random() * 1000 * 2 ** (attempt - 1);
    await new Promise((resolve) => setTimeout(resolve, delayMs));
  }
}

See these errors grouped, and know when the API is down

RealUptime Errors takes errors from any Sentry SDK. Tag each failed call with the provider, status and model, and errors from the same code group into one issue with its count and first and last time seen, so a run of 429s shows up as one rising issue instead of a flood:

import * as Sentry from "@sentry/node";

// The DSN from your RealUptime Errors project settings.
Sentry.init({ dsn: process.env.REALUPTIME_ERRORS_DSN });

if (!response.ok) {
  Sentry.captureException(new Error(`OpenAI ${response.status}`), {
    tags: { ai_provider: "openai", ai_status: response.status, ai_model: model },
    fingerprint: ["openai", String(response.status)],
  });
}

RealUptime Monitor can check an API endpoint from several regions every minute and alert you when it fails, and the OpenAI outage page can alert you when OpenAI reports an incident. Both are free to start.

Start Errors free

Related errors

OpenAI's own reference: platform.openai.com/docs/guides/error-codes. How our checks work: methodology.