In this article
Parse both Retry-After forms, then apply the remaining deadline and duplicate-safety policy.
A rate-limited inference client retries immediately because it only understands Retry-After as an integer. Another endpoint sends a date. The server’s guidance is then discarded, and multiple application workers can create a burst precisely when the service needs less load. Parse the field’s actual grammar before tuning the retry backoff.
Distinguish duration from date
Retry-After can express a delay in seconds or an HTTP date. Classify the value before converting it. An absolute date requires a wall-clock interpretation; a relative delay does not. Reject malformed values through a documented fallback instead of treating an unsuccessful parse as zero. Preserve the redacted raw value and parse outcome in a test log so the difference between missing guidance and invalid guidance remains visible.
Convert waiting into a bounded schedule
After calculating an allowed delay, schedule the actual wait against a monotonic clock. Wall-clock corrections should not make an already established delay unexpectedly vanish or stretch without bound. Keep the total request deadline, maximum attempts and application cancellation active while waiting. If the proposed retry falls outside the remaining budget, surface that outcome rather than beginning work the caller can no longer use.
Read the status and application contract
The presence of retry guidance does not by itself prove that repeating generation is safe. Determine whether the service rejected admission or may have already started a request. A rate-limit response and a connection break during streaming have different evidence. Apply the API’s documented duplicate-handling behavior, where available, and preserve a distinct identifier for each attempt. Do not infer an idempotency guarantee from a delay field.
Test multiple workers together
A correct parser in a single client can still produce synchronized retries when many workers receive the same deadline. Coordinate the retry budget across the application and use an appropriate spreading policy without retrying earlier than the server allows. Verify that pending retries do not occupy unbounded worker memory. A queue that keeps every rejected prompt indefinitely changes a rate-limit incident into a local resource problem.
Preserve the reason a pending attempt was abandoned. Expiration of the caller deadline, cancellation, an invalid delay value and exhaustion of the attempt budget are different outcomes. Distinguishing them prevents an operator from interpreting every locally stopped retry as another rejection by the inference service.
Check edge cases before rollout
Include a relative value, a future date, a date already in the past, an absent field and malformed content. Simulate clock offset without changing a production host’s time. Confirm cancellation during the wait and exhaustion of the overall deadline. Acceptance means the application obeys usable guidance, remains bounded when guidance is unusable, and reports why it stopped. It does not mean the next attempt is guaranteed acceptance: Retry-After is scheduling information, not a reservation of future model capacity or a promise of successful output.
Primary references
HTTP Semantics. Defines Retry-After as either delay seconds or an HTTP date.
Additional HTTP Status Codes. Defines the rate-limit response and its optional retry guidance.
Problem Details for HTTP APIs. Supports explicit error details when the client cannot safely schedule another attempt.
Related reading: Provider overload: Retry-After as part of the contract; Request deadlines: budgeting queueing, prefill and streaming.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.