Reference
Retries
When and how to retry.
Retry 429 and 5xx responses with exponential backoff, honouring Retry-After on 429. Use an Idempotency-Key so retries are never double-billed. The official JavaScript SDK does exactly this.
The Python SDK retries the same way: 429 and 5xx responses are retried up to max_retries times (default 2), honouring Retry-After.