VanaAPI

← Écrits

How to Handle 429 Rate Limit Responses Gracefully

Formats d'échangeEN2026-10-25

A 429 response means the server is limiting your request rate. Treat it as a signal to slow down, not an instruction to resend immediately. The HTTP standard allows a Retry-After header, but does not require one, so your client needs a fallback policy. ([rfc-editor.org](https://www.rfc-editor.org/rfc/rfc6585.html))

For a Vana API integration, keep recovery logic in the client layer that sends requests to its shared endpoint. One address simplifies configuration; your application should still define how long it can wait and when it must stop. ([vanaapi.com](https://vanaapi.com/))

§ Step 1: Inspect the response before retrying

Capture the HTTP status, error body, response headers, and any request identifier. Do not classify failures solely by a message containing “limit.” For example, OpenAI distinguishes temporary rate limits from quota or billing problems; repeatedly retrying the latter does not resolve them. Inspect the actual response rather than assuming every integration uses identical error fields. ([developers.openai.com](https://developers.openai.com/api/docs/guides/error-codes?utm_source=openai))

  • Temporary throttling: enter the bounded retry flow.
  • Exhausted quota or billing restriction: stop and surface the required account action.
  • Unclear cause: retain diagnostic details and avoid an unlimited retry loop.

§ Step 2: Respect Retry-After when present

Parse Retry-After as either a nonnegative number of seconds or an HTTP date. For a date, calculate the remaining wait and clamp negative results to zero. These are the two formats defined by HTTP. ([rfc-editor.org](https://www.rfc-editor.org/rfc/rfc9110.html))

Treat a valid server delay as a minimum. If the response requests 20 seconds, do not shorten that to your normal five-second backoff. If the delay exceeds the operation’s remaining deadline, defer the job or return a controlled failure instead of retrying early. Use fallback backoff when the header is absent or invalid. ([developers.openai.com](https://developers.openai.com/api/docs/guides/rate-limits))

§ Step 3: Add exponential backoff with jitter

Without a usable server hint, increase the delay after each failed attempt and randomize it. Exponential backoff reduces repeated pressure, while jitter keeps clients from retrying together. ([github.com](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_handle_rate_limits.ipynb?short_path=0e70e57&utm_source=openai))

As an application policy, start with a one-second base and a 30-second cap. Before each retry, double the previous delay ceiling until it reaches the cap, then choose a random wait between zero and that ceiling. Your first three retry windows would be zero to one, zero to two, and zero to four seconds. These are example settings, not published Vana API limits.

§ Step 4: Set one retry budget

Choose one layer to own retries. The official OpenAI JavaScript SDK retries eligible failures, including 429 responses, twice by default and exposes maxRetries to change that behavior. Check your installed SDK’s settings before adding an outer loop; nested retries can multiply outbound attempts. ([developers.openai.com](https://developers.openai.com/api/reference/typescript))

For an initial interactive policy, allow four total attempts, including the original request, within a 30-second overall deadline. Stop when either budget runs out. Keep cancellation active during requests and waits. For background work, persist a future execution time instead of holding a worker indefinitely.

§ Step 5: Control traffic before it reaches the API

Put outgoing requests behind a bounded queue. Set separate controls for request pacing and in-flight concurrency. After repeated throttling, reduce admission to the affected queue and restore it gradually after successful requests. Keep retries inside the same controls rather than giving them a bypass.

For multiple application instances, coordinate the limiter across workers sharing the same configured scope. Keep scope configurable rather than assuming that every model or protocol has an independent allowance. When the queue is full, reject or defer new work explicitly.

§ Step 6: Test recovery and make failures visible

Test a valid seconds header, a date header, a missing header, repeated 429 responses, cancellation, and deadline exhaustion. Verify the number of actual outbound attempts, not just application-loop iterations. For streaming, do not automatically replay after consuming output; errors after streaming begins need separate handling. ([developers.openai.com](https://developers.openai.com/api/docs/guides/rate-limits))

Log retry counts, wait durations, queue depth, and final outcomes without storing API keys or sensitive prompts. Show users a clear waiting or failure state. Create a Vana API account when you are ready to connect your client, then validate this recovery policy under controlled traffic before increasing load.