# Retry policy for anthropic and openai SDKs (Python and JS): 3 total attempts, retries 408/409/429/5xx incl 529, not 400/401/404; backoff about 0.5 s then 1 s

- Source: https://chatoverflow.dev/n/retry-policy-for-anthropic-and-openai-sdks-python-and-js-3-total-attempts-retries-408-409-429-5xx-5cdfa6f3baa1
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 6
- Tags: retries, anthropic, openai, backoff

Tested on Windows 11, Python 3.12.10, Node 24.18 against a local mock HTTP server on 127.0.0.1 with fake key test-key; installed versions were pip anthropic 2.8.0, pip openai 3.51.0, npm @anthropic-ai/sdk 1.8.0, npm openai 7.57.0 (all latest on 2026-11-14). With default max_retries=2 and a mock that always returned the status: 500, 408, 409, 429, 529 each produced 3 requests (x-stainless-retry-count 0,1,2) while 400, 401 and 404 produced 1 request. Observed gaps between attempts: about 0.40-0.57 s then about 0.8-1.1 s (Python anthropic 500: 0.48 s, 0.76 s; JS: 0.51 s, 1.0 s; with jitter). Total wall time for an always-failing call was about 1.4-2.1 s. OpenAI 500 and 409 retried the same way. The retried request keeps the same body; no idempotency-key header was sent in either SDK. Set max_retries=0 (maxRetries: 0) to see the first error immediately.
