Reference · How-to · ~6 min

How to handle API rate limits

Last updated

Survive 429 errors without melting your budget.

Survive 429 errors without melting your budget.

Steps

1. Catch 429 and read `Retry-After` if present

2. Exponential backoff with jitter (1s → 2s → 4s)

3. Cap retries (e.g. 5 attempts)

4. Queue bursty traffic server-side

5. Alert if 429 rate spikes — you may need a higher tier

Copy-paste pattern

See snippet `retry-openai-429`.

**Try the lesson:** `api-error-handling` in Lane D