OpenAI API error 429 rate limit exceeded fix

You're getting "Error 429: Rate limit exceeded" from the OpenAI API and your application just stopped working. This hits developers hard during peak usage or when testing new features with tight loops.

OpenAI API error 429 rate limit exceeded fix

You're getting "Error 429: Rate limit exceeded" from the OpenAI API and your application just stopped working. This hits developers hard during peak usage or when testing new features with tight loops.

What's actually happening

Error 429 means you've sent too many requests to OpenAI's servers in a short time period. The API enforces rate limits measured in three ways: requests per minute (RPM), tokens per minute (TPM), and requests per day (RPD). Your specific limits depend on your usage tier and which models you're calling.

When you exceed any of these limits, the API returns this exact response:

```

{

"error": {

"message": "Rate limit reached for requests",

"type": "requests",

"code": "rate_limit_exceeded"

}

}

```

Free tier accounts typically get 3 RPM and 40,000 TPM for GPT-3.5-turbo. Paid accounts start at 3,500 RPM and 90,000 TPM, scaling up as you spend more. The error header `Retry-After` tells you exactly how many seconds to wait before trying again.

How to fix it

1. Check your current rate limits

Go to platform.openai.com/account/limits. This page shows your exact RPM, TPM and RPD limits for each model. Compare these numbers against your application's request volume.

2. Add exponential backoff to your code

Wrap your API calls in retry logic that waits progressively longer between attempts:

```python

import time

def call_api_with_backoff(max_retries=5):

for i in range(max_retries):

try:

response = openai.chat.completions.create(...)

return response

except openai.RateLimitError:

wait_time = (2 ** i) + random.uniform(0, 1)

time.sleep(wait_time)

```

This prevents hammering the API when you're already over limit.

3. Implement request batching

If you're making hundreds of individual calls, combine them. Instead of sending 100 separate prompts, batch them into fewer requests with multiple messages or use the Batch API at platform.openai.com/batches for non-urgent processing.

4. Reduce token usage per request

Lower your `max_tokens` parameter. If you're setting it to 4000 but only using 500 tokens in responses, you're burning through your TPM limit four times faster than necessary. Check actual token usage in the API response under `usage.total_tokens`.

5. Request a rate limit increase

Click the "Request increase" button on platform.openai.com/account/limits. Provide your use case, expected traffic, and payment history. OpenAI typically responds within 2-3 business days. Higher usage tiers unlock automatically as you spend more—Tier 2 starts at $50 total spend, Tier 3 at $100.

If batching doesn't help and you're still hitting limits on paid tier, check you haven't accidentally created multiple parallel loops calling the API—this is the most common mistake in production code.

If that doesn't work

You might be seeing 429 errors for a different reason: insufficient quota. The error message will specifically say "You exceeded your current quota". This means your account has hit its billing limit or has no payment method attached. Go to platform.openai.com/account/billing/overview and add a payment method or increase your usage limit under "Set monthly budget".

For genuine rate limit issues that persist after implementing backoff and batching, contact OpenAI through platform.openai.com/account/limits by clicking "Help" then "Messages". Include your organization ID, the specific model throwing errors, and your current daily request volume. For guidance on how to contact OpenAI support effectively, check the detailed contact guide.

If you're seeing other error codes alongside 429—like 500 or 503—read about OpenAI API error 429 and other API errors for comprehensive troubleshooting.

Questions people actually ask

Q: How long do I have to wait before trying again?

A: Check the `Retry-After` header in the error response. It gives you the exact seconds to wait. Without that header, start with 1 second and double it with each retry.

Q: Will upgrading to ChatGPT Plus increase my API limits?

A: No. ChatGPT Plus is separate from API access. API limits depend only on your API usage tier at platform.openai.com/account/limits.

Q: Can I pay to remove rate limits entirely?

A: No, but limits increase significantly as you reach higher usage tiers. Tier 5 accounts get 10,000 RPM and 30,000,000 TPM for GPT-4.

What to remember

  • Check platform.openai.com/account/limits for your exact RPM and TPM numbers
  • Always implement exponential backoff in production code
  • Batch requests together instead of firing them individually
  • Use only the `max_tokens` you actually need
  • Higher spending unlocks higher tiers automatically—Tier 2 at $50, Tier 3 at $100

---

*openai-support.com is an independent resource, not affiliated with OpenAI Inc.*

Related help