429, 408, 500, network drops) are normal in any networked service. The right response is exponential backoff with jitter, applied only to retryable errors. Both SDKs ship with a configurable retry policy out of the box.
What to retry
| Status / failure | Retryable? | Notes |
|---|---|---|
408 Request Timeout | โ | Server side โ wait briefly and retry. |
429 Too Many Requests | โ | Rate limit; back off. |
500 Internal Server Error | โ | Treat as transient. |
502, 503, 504 | โ | Network/upstream โ retry with backoff. |
| Network errors (DNS, broken pipe, connect timeout) | โ | Retry โ these are pure transport failures. |
400, 401, 402, 403, 404, 413, 415 | โ | Caller-side problem โ fix the request first. |
SDK configuration
Both SDKs accept a retry config at the client level and per-call.- Python
- TypeScript
429, 5xx) with exponential backoff, capped at 1 minute between retries and 1 hour total. Tune the numbers to your latency SLO.
Manual retry pattern
If you call the REST API directly or want to wrap the SDK with your own logic:Choosing the right backoff
429from rate limiting โ initial wait of 500โ1000 ms doubles to 30โ60 s; cap retries at 3โ5 attempts.500/5xxfrom transient errors โ same shape, slightly more aggressive (300 ms initial) since they usually clear quickly.- Streaming requests โ retrying a partial stream is fine if you havenโt started playback yet; once playback has begun, itโs usually better to fail than to splice in fresh audio. Decide based on UX.
- Long-text auto-chunking โ both SDKs apply the same retry policy to each underlying segment, so a single long-text call effectively has the retry budget per segment.
Idempotency
Supertone API calls are idempotent in effect โ the same request produces the same audio output (modulo small synthesis variability). Retrying a successful-but-aborted request wonโt double-bill you for credits as long as the original request didnโt produce billed audio. For voice-cloning uploads, retries do create separate voices each time if the upload completes. If you re-upload after a network blip, verify whether the previous attempt actually finished before posting again โ otherwise youโll end up with duplicate voices inlist_custom_voices.
Anti-patterns to avoid
- Retrying
4xx(other than429) โ these donโt get better with time. Fix the request. - No upper bound โ always cap the number of attempts and the total elapsed time.
- No jitter โ fixed-delay retries cause thundering-herd patterns under widespread failures.
- Retrying inside a loop without backoff โ burns through credits and rate-limit budget in seconds.
Related
Rate limits
What triggers
429 in the first place.Error handling
Full reference of error codes and SDK error classes.