Size your retry behavior before it bites you in production
LLM APIs throttle and occasionally fail, so any serious integration needs retry logic. Get the parameters wrong and you either give up too soon or stack delays that blow past your request timeout. This calculator turns your base delay, retry count, multiplier, and jitter choice into a concrete schedule — every attempt’s delay, the running total, and the worst-case budget you need to allow.
How it works
For attempt number n (starting at zero), the base delay before that attempt is:
delay(n) = min(max_delay, base_delay × multiplier^n)
The tool applies your chosen jitter mode to that computed delay, then sums the upper bound of every delay across all attempts to give the worst-case cumulative wait. Add your per-call API latency on top to arrive at the total timeout budget you need to allow.
The three jitter modes
No jitter — delays are exact: 1s, 2s, 4s, 8s. Simple, but if many clients start at the same time, they all hit the same retry schedule and generate synchronized spikes — the thundering herd problem.
Full jitter — each delay is a random value between 0 and the computed cap. This spreads retries across the full window so bursts cannot synchronize. It is the approach recommended by AWS for its own APIs and is the best default for most cases.
Equal jitter — half the delay is fixed (the computed cap divided by 2) and the other half is randomized. This guarantees a minimum wait per attempt (so clients cannot accidentally retry immediately) while still spreading load.
A multiplier of 2 with full jitter is the well-tested default for most API clients.
Which errors to retry — and which not to
Never retry indiscriminately. Retrying a 400 Bad Request burns your budget and delays surfacing the real problem. The rule is:
| HTTP status | Retry? | Reason |
|---|---|---|
| 429 Too Many Requests | Yes — honor Retry-After | Transient rate limiting |
| 500 Internal Server Error | Yes | Transient server fault |
| 502 Bad Gateway | Yes | Transient upstream fault |
| 503 Service Unavailable | Yes | Server temporarily overloaded |
| 504 Gateway Timeout | Yes | Upstream timeout |
| Network timeout / connection reset | Yes | Transient connectivity |
| 400 Bad Request | No | Fix the request |
| 401 Unauthorized | No | Fix the credentials |
| 403 Forbidden | No | Fix permissions |
| 404 Not Found | No | Fix the endpoint |
| 422 Unprocessable Entity | No | Fix the request body |
When the API returns a Retry-After header on a 429, use that value as your
delay instead of the computed exponential delay. The calculator covers cases where
no such header is returned.
Setting a realistic timeout budget
Your overall request timeout must be at least:
timeout = (per-attempt latency × max_retries+1) + sum of all delays (worst case)
If a single LLM call can take up to 30 seconds and you allow 3 retries with a worst-case delay sum of 15 seconds, your client timeout should be at least 135 seconds — not 30. The schedule the calculator generates makes this arithmetic explicit before you discover it in a production outage.