Skip to main content
503Retryable

OpenAI 503 Engine Overloaded

OpenAI's capacity for the model is saturated — the equivalent of Anthropic's 529. Your request was fine; the fleet was busy.

Most likely causes

  1. 1.Demand spike on a popular model
  2. 2.Large synchronized retry waves industry-wide during incidents

Fix checklist

  • Retry with exponential backoff and jitter
  • Fall back to a sibling model (e.g. mini variant) for non-critical paths
  • Move offline work to the Batch API

Retry guidance

Exponential backoff with full jitter from 1s, cap 32s, up to 6 attempts.

// Retry 503 with exponential backoff + full jitter.
async function callWithBackoff(payload: unknown, maxAttempts = 5) {
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    const res = await fetch("https://api.openai.com/v1/chat/completions", {
      method: "POST",
      headers: {
        "content-type": "application/json",
        Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
      },
      body: JSON.stringify(payload),
    });
    if (res.status !== 503) return res;
    // Honor Retry-After when present; otherwise exponential backoff, capped at 32s.
    const retryAfter = Number(res.headers.get("retry-after"));
    const base = Number.isFinite(retryAfter) && retryAfter > 0
      ? retryAfter * 1000
      : Math.min(1000 * 2 ** attempt, 32_000);
    await new Promise((r) => setTimeout(r, base * (0.5 + Math.random() * 0.5)));
  }
  throw new Error("OpenAI 503: still failing after backoff — check https://status.openai.com");
}

Provider status page: status.openai.com