Skip to main content
503Retryable
Google Gemini 503 Unavailable
The service is temporarily overloaded or down — Gemini's capacity-shed signal, equivalent to Anthropic's 529 / OpenAI's 503.
Most likely causes
- 1.Model fleet saturated (common on newest models at launch)
- 2.Regional capacity constraints
Fix checklist
- Retry with exponential backoff and jitter
- Temporarily switch to a flash/lite variant
- For Vertex users: try a different region
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://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent", {
method: "POST",
headers: {
"content-type": "application/json",
"x-goog-api-key": process.env.GEMINI_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("Google Gemini 503: still failing after backoff — check https://status.cloud.google.com");
}Provider status page: status.cloud.google.com