JupiteX Get the app
Science & Technology28 Nov 2026 · about 7 min

Three layers of "retry 3 times" turn one failed LLM call into 27 paid ones

The brief

Retries multiply when they are nested. If the SDK, your code, and the job queue each allow three attempts, one original request can trigger three attempts at each level. That makes 3 × 3 × 3, or 27 model calls before the request gives up. The layers may each seem sensible alone, but together they can create a large burst of calls. For example, the queue starts a task, your code calls the SDK, and the SDK tries the provider. If that attempt fails, each layer can start another round. The SDK does not know the queue may rerun the whole task, and the queue does not know the SDK already sent multiple calls. Their independent retry counts multiply rather than simply adding together. The impact is greatest when failures persist, such as during an outage or rate limit. In the article’s example, 1,000 requests during an hour of provider trouble can become 27,000 attempts. Retry in exactly one place, set a time budget, and turn off retries in the other layers for that call.

01

How can three layers making three attempts each turn one failed request into 27 model calls?

Retries multiply when they are nested. If the SDK, your code, and the job queue each allow three attempts, one original request can trigger three attempts at each level. That makes 3 × 3 × 3, or 27 model calls before the request gives up. The layers may each seem sensible alone, but together they can create a large burst of calls.

For example, the queue starts a task, your code calls the SDK, and the SDK tries the provider. If that attempt fails, each layer can start another round. The SDK does not know the queue may rerun the whole task, and the queue does not know the SDK already sent multiple calls. Their independent retry counts multiply rather than simply adding together.

The impact is greatest when failures persist, such as during an outage or rate limit. In the article’s example, 1,000 requests during an hour of provider trouble can become 27,000 attempts. Retry in exactly one place, set a time budget, and turn off retries in the other layers for that call.

02

Which parts of an application can retry the same LLM request without knowing that other parts already tried?

Several parts of an application can retry an LLM request independently. The SDK may retry certain failures before your code sees an exception. Your code may also use a retry helper or a loop. A background job queue, such as Celery, RQ, or a cloud queue, can rerun a task after marking it failed.

A nightly cron job can add another layer by rerunning work that did not finish. Each part sees a failure at its own level and starts its own retry round. For instance, the queue may retry a task even though the SDK already made several provider calls during the first run. The layers do not automatically share knowledge of those attempts.

This is why retry settings need to be checked across the whole path, not just in one function. Look up the SDK’s max_retries setting, review application code, and inspect queue behavior. Choose one retry owner for the call, then disable retries elsewhere or make the queue wait a long time before retrying.

03

In the article’s example, what would 1,000 requests during a one-hour outage cost with three retry layers?

The example estimates a $270 bill for 1,000 requests during a one-hour outage with three retry layers. The key jump is from requests to attempts: three layers, each allowing three attempts, can turn each failed request into 27 calls. Across 1,000 requests, that is 27,000 attempts in the hour.

Each attempt in the example costs $0.0100. That price comes from a call with 2,000 input tokens and 500 output tokens, using the stated list prices of $2 per million input tokens and $12 per million output tokens. Multiplying 27,000 attempts by $0.0100 gives $270. The usual hourly spend for these 1,000 requests is $10.

The estimate assumes the provider is overloaded and every attempt times out after the model has done the work, so each is billed in full. Actual timeout billing varies by provider. The article advises checking the usage dashboard after a bad hour; regardless of billing, the 27-fold attempt count remains.

04

Why might a request still be billed after the client times out without receiving an answer?

A timeout is the client giving up while waiting for a response. It does not prove that the model stopped generating. The request may already be doing work on the provider’s side even though no answer reaches the client. This matters because a failed-looking call can still use billable resources.

In the article’s outage example, the provider is overloaded and each attempt times out after the model has already done the work. The estimate assumes every such attempt is billed in full. With three retry layers, the client may time out repeatedly and send many more attempts, increasing possible charges without producing an answer.

Billing depends on the provider and the request’s outcome. Some providers stop generation when the client disconnects, some charge only for what was generated, and rejected requests such as most rate-limit errors usually cost nothing. Check the usage dashboard after an incident to learn which case applies. The retry count can still multiply even when every attempt is not billed in full.

05

What is a transient error, and how is it different from a permanent error like an invalid API key?

A transient error is a failure that may go away by itself. The article gives a dropped connection as an example. Retrying can make sense when the next attempt has a chance to succeed, because the underlying problem may have passed. Timeouts, connection drops, rate limits, and server errors are listed as errors to consider retrying.

A permanent error does not become fixed just because the same request is sent again. An invalid API key is the article’s example: the request will keep failing the same way. A request that is too large is another example of an error that will not be helped by repeating it. These failures call for correcting the request or configuration, not another attempt.

The distinction helps avoid wasteful calls. Put retries in one place and limit them by time as well as attempt count. Retry only failures that can go away, rather than treating every exception as temporary. During widespread failures, stop sending requests for a while instead of letting many clients repeatedly retry.

06

Why can retries help with occasional random failures but worsen an outage or rate limit?

Retries can help when failures are random and independent: each attempt has the same chance of failing, regardless of the last one. With a 5% failure rate, one layer of three attempts leaves a request unanswered only when all three fail. That is 0.05³, or 125 unanswered requests per million. A second layer reduces that further, while later layers have almost nothing left to fix.

An outage or rate limit is different. Failures are not independent if the provider remains overloaded or continues rejecting requests. New attempts are then likely to fail too, but they still reach the service. With three layers of three attempts, a request can produce 27 calls. The article’s example scales this to 27,000 attempts for 1,000 requests during an hour of provider trouble.

On a normal day, extra layers have almost no expected-attempt cost: 1.0525 with one layer and 1.0526 with four. That can hide the risk until failures persist. Use one retry layer with a time budget, and stop sending briefly when many requests fail at once.

07

What is a circuit breaker, and how can it keep an overloaded service from receiving more failing requests?

A circuit breaker is a way to respond when many requests start failing at once. Instead of retrying every failing request and continuing to send traffic, the system stops sending for a while. This can keep repeated failures from adding more requests to a service that is already struggling.

The article describes a simple pattern: after N failures in a row, fail fast for a while, then let one test request through. If that test request can proceed, normal calls can resume; if not, the pause avoids immediately sending another crowd of failing requests. The article does not specify a particular value for N or how long the pause should last.

The breaker complements, rather than replaces, a single retry layer. Retries may help an occasional timeout or dropped connection, but repeated failures can point to an outage or rate limiting. Pausing during a wave of failures limits extra attempts and potential costs. It does not provide answers during an outage; a fallback model is a separate option with its own price.

This brief was written by AI from the original reporting and checked by other models. Names, figures and quotes come from the source; read it for full context.

Read more in the JupiteX app

Pulse is free. New stories every 4 hours, each one broken into the questions that explain it.

Or read more news on the web