- On
429, wait at leastRetry-After. - On
502/503withoutRetry-After, double the wait each attempt (1s, 2s, 4s, 8s). - Add random jitter.
- Cap attempts and maximum wait, then surface the error with its
X-Request-ID.
Retry-After beats your computed backoff.
Pseudocode
Circuit Breaker
After consecutive provider failures the gateway stops routing to that provider for a cooldown window, then probes before reopening. During cooldown you may see503 unavailable or 502 provider_error; an open-circuit rejection never dispatched, so it is safe to retry with backoff.

