API returns 429 Too Many Requests / rate limit exceeded (OpenAI, Anthropic, GitHub, any REST API)
#143Error
429 Too Many Requests: rate limit exceeded (RateLimitError / rate_limit_error / secondary rate limit)
Why it happens, and why this works
The server allows only so many requests or tokens per time window per key, and 429 means that window is full. Backing off lets the window reset, and limiting concurrency keeps you under the limit instead of bursting past it.
Fix
Slow down and retry with backoff instead of hammering the API. 1. Retry 429s with exponential backoff plus jitter: wait 1s, 2s, 4s, 8s (+ random 0-500ms), max ~5 tries. 2. If the response has a Retry-After header (seconds or a date), wait exactly that long instead. 3. Cap concurrency (e.g. p-limit / asyncio.Semaphore with 2-5 at a time) rather than firing every request with Promise.all. 4. Official SDKs already retry: raise maxRetries / max_retries instead of writing your own loop. 5. If it's a quota (daily/monthly limit, insufficient credits) not a rate, retries won't help; tell the user.
Did it work?
No reports yetRelated fixes
anthropic.RateLimitError: Error code: 429 (rate_limit_error)
#163anthropic.RateLimitError: Error code: 429 - {'type': 'error', 'error': {'type': 'rate_limit_error', 'message': 'This request would exceed the rate limit for your organization'}}
GH001: Large files detected, file exceeds GitHub's file size limit of 100.00 MB
#109remote: error: File data/model.bin is 120.00 MB; this exceeds GitHub's file size limit of 100.00 MB remote: error: GH001: Large files detected. You may want to try Git Large File Storage
openai.AuthenticationError: Error code: 401 - Incorrect API key provided
#164openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-proj-****. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'code': 'invalid_api_key'}}