OpenAI API 401: Incorrect API key provided
OpenAI returns 401 Incorrect API key provided? The key in the request is not correct. It may have a typo, belong to another project, or be deleted.
Reviewed October 24, 2026
What it means in plain English
OpenAI's error-code guide lists 401 - Incorrect API key provided with the cause: the requesting API key is not correct. Its solution is to make sure the API key used is correct, clear your browser cache, or generate a new one.
401 - Invalid Authentication is a different message on the same page. OpenAI says that one means the authentication credentials are invalid, for example a revoked key, a key that is not the one assigned to the requesting organization or project, or a key without the permissions the endpoint needs.
Likely causes
OpenAI lists these reasons for Incorrect API key provided:
- The API key contains a typo or an extra space.
- The API key belongs to a different organization or project.
- The API key has been deleted or deactivated.
- An old, revoked API key is cached locally.
How to fix it, step by step
- Read the full error message in your server logs. Stay on this page when it says
Incorrect API key provided. If it saysInvalid Authentication, check the key and organization ID in the request header instead. - Check that the request header uses the correct API key. Look for a typo or an extra space in the value your app reads.
- Check that the key belongs to the organization and project you expect. OpenAI says project keys are under General settings after you select the project.
- OpenAI says to try clearing your browser's cache and cookies, then try again.
- If you are not sure the key is correct, generate a new one. Replace the old key in your codebase. OpenAI says to follow its best practices guide when you replace the key.
- Keep the key on the server. See OpenAI API key in the browser.
How to check it worked
- The same request no longer returns
401 - Incorrect API key provided. - If the next error is a 429, that is a quota or rate-limit error, not a key error. See OpenAI API 429.
Sources
Related fixes
More AI API errors fixes
Keep going on your own.
The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.