OpenAI API error 429, 401, 500, and 503 — what each code means and exactly how to fix it

Your API call just failed with a cryptic error code. You're staring at 429, 401, 500, or 503 in your logs, and your application's dead in the water. These four errors account for about 80% of all API failures, and each o

OpenAI API error 429, 401, 500, and 503 — what each code means and exactly how to fix it

Your API call just failed with a cryptic error code. You're staring at 429, 401, 500, or 503 in your logs, and your application's dead in the water. These four errors account for about 80% of all API failures, and each one means something completely different.

What's actually happening

Error 429 means you've hit a rate limit. OpenAI throttles how many requests you can make per minute based on your tier. If you're on the free tier, you're limited to 3 requests per minute for GPT-4. Paid tier 1 gets 500 requests per minute. When you exceed this, the API returns `429 Too Many Requests` with a message like "Rate limit reached for requests."

Error 401 is an authentication failure. Your API key is wrong, missing, or revoked. You'll see `401 Unauthorized` with text like "Incorrect API key provided" or "Invalid authentication credentials." This happens when you copy-paste your key incorrectly, use an old key after regenerating, or forget the `Bearer` prefix in your auth header.

Error 500 means OpenAI's servers encountered an internal error. This is on their end, not yours. The full message is `500 Internal Server Error`. It's usually temporary — a bug in their code or a backend service failing.

Error 503 is a capacity issue. OpenAI's systems are overloaded. You'll get `503 Service Unavailable` with messages like "The server is temporarily unable to service your request." This spikes during peak US hours or when a new model launches and everyone hammers the API.

How to fix it

For 429 errors:

  • Log into platform.openai.com/account/limits and check your current rate limits
  • Look at the `retry-after` header in the error response — it tells you exactly how many seconds to wait
  • Add exponential backoff to your code. Wait 1 second, then 2, then 4, then 8 before retrying
  • If you need higher limits immediately, go to platform.openai.com/account/billing and add $50+ in prepaid credits. Your tier increases automatically after you spend $5, $50, or $1,000
  • For urgent production needs, use the "Increase rate limits" button on the limits page. OpenAI reviews requests within 24-48 hours if your account is in good standing

For 401 errors:

  • Go to platform.openai.com/api-keys
  • Click "Create new secret key" and copy it immediately — you can't view it again
  • Check your code uses `Authorization: Bearer sk-...` in the header (note the space after "Bearer")
  • If using environment variables, restart your application after updating the key
  • Verify you're not accidentally using a ChatGPT Plus subscription key — those don't work for API access

For 500 errors:

  • Wait 10 seconds and retry once
  • Check status.openai.com to see if there's a known incident
  • If the error persists for more than 5 minutes, switch to a different model temporarily (gpt-3.5-turbo instead of gpt-4)
  • Log the full error response including the request ID and timestamp
  • If it's blocking production for over an hour, contact help.openai.com with your request IDs

For 503 errors:

  • Implement retry logic with 30-second delays between attempts
  • Check status.openai.com — if there's an outage, you just have to wait
  • Queue your requests instead of sending them all at once
  • Consider using batch API endpoints for non-urgent tasks
  • If this happens regularly during your peak hours, shift your workload to off-peak times (late US night/early morning UTC)

If that doesn't work

Email help.openai.com with:

  • Your organization ID (found at platform.openai.com/account/organization)
  • The exact error message including the request ID
  • Timestamp of when it started
  • What you've already tried

For 429 and 401 errors, expect a response within 2-4 days. For 500/503 errors lasting over an hour, they typically respond within 8 hours. Don't send multiple emails — it slows down their queue.

Questions people actually ask

Q: Can I pay to skip rate limits entirely?

A: No. Even tier 5 accounts (after spending $1,000+) have limits — they're just much higher. Rate limits exist to prevent abuse and ensure system stability for everyone.

Q: Why do I get 401 when my API key looks correct?

A: Check for invisible characters if you copy-pasted. Also verify your key starts with `sk-proj-` (project key) or `sk-` (legacy). User keys starting with `user-` don't work for API calls.

Q: How long do 503 errors usually last?

A: Typically 10-30 minutes. During major incidents (like a new GPT model launch), they can last 2-4 hours. Check status.openai.com for updates.

Q: Does error 429 mean I'm being charged?

A: No. Failed requests don't count toward your bill. You only pay for successful API calls that return a 200 status code.

What to remember

  • 429 means slow down — add delays and check your tier limits
  • 401 means bad credentials — regenerate your API key at platform.openai.com/api-keys
  • 500 is OpenAI's problem — wait and retry, then check status.openai.com
  • 503 means overloaded servers — retry with longer delays or wait for off-peak hours
  • Always implement exponential backoff in production code to handle temporary failures gracefully

---

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

Related help