OpenAI API 401 Unauthorized (authentication error)

Is there an outage right now?

OpenAI API is currently reporting issues. This error may be caused by a wider outage.

Updated: Jul 21, 2026, 8:02 PM UTC

View OpenAI API status

What this error means

401 means authentication failed: invalid/expired/missing API key, or wrong org/project.

Common causes

  • Wrong, expired, or deleted API key
  • Malformed Authorization header (missing Bearer)
  • Env var not loaded (unset / typo)
  • Wrong Organization / Project
  • Insufficient key permissions

How to fix

  1. 1.Reissue the API key and set it correctly via env
  2. 2.Use `Authorization: Bearer <KEY>` format
  3. 3.Read the key from env, not hardcoded
  4. 4.Pass the correct Organization/Project
  5. 5.Check the key scopes/permissions

When waiting helps (and when it won't)

401 is a config issue—waiting will not fix it. Re-check key, header and env vars.

Alternatives when OpenAI API is down

Claude APIGemini API / AI StudioMistral APIDeepSeek APIGroq API

Related errors

FAQ

What is 401 Unauthorized?

401 means authentication failed: invalid/expired/missing API key, or wrong org/project.

How do I fix 401 Unauthorized?

Reissue the API key and set it correctly via env / Use `Authorization: Bearer <KEY>` format / Read the key from env, not hardcoded / Pass the correct Organization/Project / Check the key scopes/permissions

Compare OpenAI API with others