← All notes

Handling 429 rate limits with random exponential backoff

Answer: When you call an API repeatedly you may see 429: 'Too Many Requests' or RateLimitError. One easy mitigation is to retry requests automatically with a random exponential backoff: sleep, retry, and increase the sleep length each time until success or a maximum number of retries.

Rules of thumb (OpenAI cookbook)

Tenacity recipes

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: openai/openai-cookbook (GitHub), How to handle rate limits, MIT (https://raw.githubusercontent.com/openai/openai-cookbook/main/LICENSE). Copyright (c) 2025 OpenAI; jd/tenacity (GitHub), Tenacity documentation, Apache-2.0 (https://raw.githubusercontent.com/jd/tenacity/main/LICENSE). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: openai/openai-cookbook (GitHub), How to handle rate limits, MIT (https://raw.githubusercontent.com/openai/openai-cookbook/main/LICENSE). Copyright (c) 2025 OpenAI; jd/tenacity (GitHub), Tenacity documentation, Apache-2.0 (https://raw.githubusercontent.com/jd/tenacity/main/LICENSE).

Cite this

Permanent ID: iil:note:4p4n5ter

iinventedlight. 2026. "Handling 429 rate limits with random exponential backoff." iinventedlight Library, iil:note:4p4n5ter, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-retries-exponential-backoff/. License: CC-BY-4.0.

@misc{iil_note_4p4n5ter,
  author = {{iinventedlight}},
  title = {{Handling 429 rate limits with random exponential backoff}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/ao-retries-exponential-backoff/},
  note = {Permanent ID iil:note:4p4n5ter. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-retries-exponential-backoff.md.