Skip to main content
500Retryable

Anthropic 500 API Error

Something failed inside Anthropic's stack while processing an otherwise valid request.

Most likely causes

  1. 1.Transient internal failure — most resolve within seconds
  2. 2.Ongoing incident (check the status page)
  3. 3.Rarely: a pathological input tickling an internal bug

Fix checklist

  • Retry with backoff — the official SDKs already retry 500s twice
  • Log the request-id response header for support escalation
  • Check status.anthropic.com if errors persist beyond a minute

Retry guidance

Exponential backoff: 0.5s, 1s, 2s with jitter. Give up after ~3 attempts and surface the request-id.

// 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.anthropic.com/v1/messages", {
      method: "POST",
      headers: {
        "content-type": "application/json",
        "x-api-key": process.env.ANTHROPIC_API_KEY!,
      "anthropic-version": "2023-06-01",
      },
      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("Anthropic 500: still failing after backoff — check https://status.anthropic.com");
}

Provider status page: status.anthropic.com