Skip to main content
500Retryable

OpenAI 500 Server Error

An unexpected failure inside OpenAI's servers while processing the request.

Most likely causes

  1. 1.Transient internal error
  2. 2.Ongoing incident

Fix checklist

  • Retry with backoff (official SDKs default to 2 retries)
  • Capture the x-request-id header for support
  • Check status.openai.com for incidents

Retry guidance

Exponential backoff: 0.5s, 1s, 2s with jitter, max 3 attempts.

// Retry 500 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 !== 500) 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 500: still failing after backoff — check https://status.openai.com");
}

Provider status page: status.openai.com