Elevated errors on claude.ai, Claude Code, and platform.claude.com
When Claude Goes Down: Building Resilient API Integrations That Survive Elevated Error Events
A production incident at 2 AM is a bad time to discover your Claude integration has no retry logic. During elevated error periods on claude.ai, Claude Code, and platform.claude.com, raw API calls start returning 529 “overloaded” responses or 500 internal errors at rates that overwhelm any app treating the API as infinitely reliable. If your code looks like this, you’re exposed:
response = anthropic.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": user_input}]
)
# No error handling. This will raise on 529/500 during elevated errors.
Let’s talk about what actually happens during these incidents, and how to build systems that degrade gracefully rather than catastrophically.
What “Elevated Errors” Actually Means at the Infrastructure Level
Elevated error events aren’t random. They typically fall into two buckets:
Overload conditions (HTTP 529): Demand spikes faster than capacity can scale. The API is healthy but shedding load. These are usually short-lived (minutes to low tens of minutes) and affect a percentage of requests, not all of them.
Service degradation (HTTP 500/503): Something is functionally broken — a backend service, a model inference layer, or a routing component. These can last longer and may affect specific features (streaming, specific models, specific regions) while leaving others intact.
The practical difference matters: during a 529 storm, retrying with backoff often succeeds. During a true 500 degradation, retrying immediately just hammers a broken system.
Claude Code, the API platform, and the claude.ai web interface all share underlying infrastructure, which is why incidents tend to surface across all three simultaneously. A developer hitting 500s in their API calls will often notice claude.ai is also sluggish at the same moment — that’s not a coincidence.
Error Taxonomy and What to Do With Each
| HTTP Status | Meaning | Retry? | Strategy |
|---|---|---|---|
| 529 | API overloaded | Yes | Exponential backoff + jitter |
| 500 | Internal server error | Cautiously | 1-2 retries max, then fail |
| 503 | Service unavailable | Yes | Same as 529 |
| 429 | Rate limit (your quota) | Yes | Respect retry-after header |
| 400 | Bad request | No | Fix the payload |
| 401/403 | Auth failure | No | Check key, don’t retry |
The 529 is unique to Anthropic’s API and explicitly signals “try again later.” It’s not your fault, and the system is telling you it can handle the request eventually.
Implementing Robust Retry Logic
Here’s a production-grade wrapper that handles the cases above:
import anthropic
import time
import random
from typing import Optional
def create_message_with_retry(
client: anthropic.Anthropic,
model: str,
messages: list,
max_tokens: int = 1024,
max_retries: int = 5,
base_delay: float = 1.0,
) -> Optional[anthropic.types.Message]:
retryable_statuses = {529, 500, 503}
for attempt in range(max_retries):
try:
return client.messages.create(
model=model,
max_tokens=max_tokens,
messages=messages,
)
except anthropic.APIStatusError as e:
if e.status_code not in retryable_statuses:
raise # 400, 401, 403 — not worth retrying
if attempt == max_retries - 1:
raise # Exhausted retries
# Exponential backoff with full jitter
delay = base_delay * (2 ** attempt)
jitter = random.uniform(0, delay)
wait = min(delay + jitter, 60.0) # Cap at 60s
print(f"Attempt {attempt + 1} failed ({e.status_code}). "
f"Retrying in {wait:.1f}s...")
time.sleep(wait)
return None
The full jitter on backoff isn’t just nice-to-have. During a widespread incident, every client hitting the API backed off at the same time will retry at the same time — creating a thundering herd that makes the overload worse. Randomizing the wait spreads load back out naturally.
For 500 errors specifically, I cap retries at 2 before the function’s outer loop takes over. A 500 during genuine degradation means retrying aggressively is counterproductive.
Streaming and Elevated Errors: The Harder Problem
Streaming introduces a subtler failure mode. The connection can open successfully (HTTP 200) and start delivering tokens, then drop mid-stream with a network error or a sudden 500. If you’re accumulating tokens into a buffer without checkpointing, you lose everything.
accumulated_text = ""
try:
with client.messages.stream(
model="claude-sonnet-5",
max_tokens=2048,
messages=messages,
) as stream:
for text_chunk in stream.text_stream:
accumulated_text += text_chunk
yield text_chunk # Stream to your user in real time
except anthropic.APIStatusError as e:
# Stream died mid-response
if accumulated_text:
# You have a partial response — decide: surface it or retry?
yield f"\n\n[Response interrupted. Partial content above.]"
else:
# Nothing accumulated — full retry is clean
raise
In practice, I’ve found that surfacing partial content with a clear truncation marker is often better UX than silently retrying from scratch, especially for long generations. Users who’ve been watching tokens appear for 30 seconds would rather see what arrived than stare at a spinner for another 30.
Multi-Model Fallback: The Real Resilience Play
Retry logic handles transient overloads. For genuine, extended degradation, the most effective strategy is falling back to a different model or provider entirely. This is where having multi-provider access pays off operationally.
FALLBACK_CHAIN = [
{"provider": "anthropic", "model": "claude-sonnet-5"},
{"provider": "anthropic", "model": "claude-haiku-4.5"},
{"provider": "openai", "model": "gpt-6-sol"},
{"provider": "google", "model": "gemini-3"},
]
def create_with_fallback(prompt: str, clients: dict) -> str:
last_error = None
for config in FALLBACK_CHAIN:
try:
provider = config["provider"]
model = config["model"]
if provider == "anthropic":
resp = clients["anthropic"].messages.create(
model=model,
max_tokens=1024,
messages=[{"role": "user", "content": prompt}]
)
return resp.content[0].text
elif provider == "openai":
resp = clients["openai"].chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}]
)
return resp.choices[0].message.content
# Add Gemini client similarly
except Exception as e:
last_error = e
print(f"Fallback: {provider}/{model} failed, trying next...")
continue
raise RuntimeError(f"All fallbacks exhausted. Last error: {last_error}")
The fallback chain above tries a cheaper Claude model before jumping providers, since Haiku 4.5 often stays available during incidents that hit Sonnet hard (they can run on different infrastructure). If you’re managing API costs across providers anyway, a service like AI Prime Tech that consolidates Claude, GPT, and Gemini access under one account makes this fallback pattern much simpler to implement operationally.
Health-Check Monitoring Before You Hit Users
Don’t wait for user complaints to know the API is degraded. A lightweight background probe catches problems early:
# Simple health probe — run via cron or a monitoring loop
curl -s -o /dev/null -w "%{http_code}" \
-X POST https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-haiku-4.5","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
If this returns anything other than 200 for two consecutive checks (say, every 30 seconds), flip a feature flag to route traffic to your fallback provider before your users notice. The latency budget for detecting an incident should be under two minutes in any serious production system.
Practical Takeaways
- Retry 529 and 503 aggressively with exponential backoff and jitter. These are “try again” signals, not bugs in your code.
- Treat 500 errors conservatively. One or two retries is reasonable; hammering a broken backend compounds the incident.
- Never retry 400, 401, or 403. These are your problem, not the API’s, and retrying wastes quota and time.
- Checkpoint streaming responses. If a stream dies at token 800 of 1000, partial content is usually better than restarting from zero.
- Build a model fallback chain. Haiku before Sonnet before an alternate provider — this turns a potential outage into a brief quality degradation.
- Probe proactively. A cheap background health check against Haiku 4.5 gives you two-minute incident awareness instead of two-hour reactive firefighting.
- Jitter is not optional at scale. Synchronized retries during an overload incident actively worsen it. Full jitter is the standard for a reason.
Elevated error events on shared AI infrastructure are periodic facts of life, not edge cases to ignore until they happen. The difference between a team that sleeps through one and a team that gets paged is almost entirely whether they invested 200 lines of retry and fallback code before it mattered.
One API key for Claude Opus 4.8, Sonnet 4.6, Haiku 4.5, Fable 5, plus GPT & Gemini — up to 80% off official pricing, pay-as-you-go.
Get Your API Key →