Prompt
Why are my retries failing on Anthropic but not OpenAI?
Latest observation
There are a few common reasons retries can “work” with OpenAI but seem to fail with Anthropic, even when your code looks similar:
1) Anthropic may be rejecting the same request repeatedly
If the underlying issue is a bad request (invalid params, schema mismatch, unsupported tool/function setup, etc.), retries won’t help. OpenAI might be more forgiving in some cases, or your OpenAI code path may differ slightly.
Check whether the error is a:
- 4xx → usually not retryable
- 5xx / timeout / rate limit → often retryable
2) Different rate-limit behavior
Anthropic can be stricter about:
- request rate
- token throughput
- burst traffic
- concurrent requests
If you retry too quickly, you may keep hitting the same rate limit. OpenAI may tolerate your traffic pattern better.
What to do:
- use exponential backoff
- add jitter
- respect any
Retry-Afterheaders - reduce concurrency
3) You may be retrying on the wrong exceptions
Some SDKs or wrappers classify errors differently across providers.
Make sure you’re retrying on:
- network errors
- timeouts
- 429s
- 500s / 502s / 503s / 504s
But not on:
- validation errors
- auth errors
- context length errors
4) Anthropic request formatting may be different
If you’re using a shared abstraction, your retry may be replaying a request that Anthropic expects in a different shape:
- message format
- tool call schema
- system prompt placement
- max tokens / model name differences
A subtle mismatch can cause every retry to fail identically.
5) Non-idempotent side effects
If your first attempt partially succeeds and your retry repeats a non-idempotent action, Anthropic may behave differently depending on how your app handles:
- tool invocation
- streaming interruptions
- conversation state mutation
6) SDK differences
Your retry logic may be implemented differently in the two client libraries:
- different default retry counts
- different timeout settings
- different handling of streaming failures
OpenAI’s SDK may automatically retry certain failures that Anthropic’s does not, or vice versa.
Best next steps
- Log the exact error type/code/message from Anthropic.
- Compare the raw request payload sent to both providers.
- Confirm whether failures are 4xx vs 5xx/429.
- Add exponential backoff with jitter.
- If using streaming, verify your retry logic can safely restart the stream.
If you want, paste:
- the exact Anthropic error
- your retry code
- the request payload
and I can tell you why it’s failing specifically.