What does 401 invalid_api_key mean?
The key is missing, malformed, wrong or revoked.
Code: invalid_api_key · HTTP status: 401
Every call needs Authorization: Bearer clsk_.... The live message for a missing key is "Missing or malformed API key. Send Authorization: Bearer clsk_...."
Common causes#
- no
Authorizationheader, orBearermissing - a key copied with a space or line break
- a key that was revoked in the Console
- an environment variable that's empty in the place the code runs
How to fix it#
- Print the first few characters of the key your code actually sends; it must start with
clsk_. - Check the key still exists in Console › API keys.
- Lost the key? It can't be shown again; create a new one.
Should my code retry?#
Don't retry: a bad key stays bad. Fix the key and send again.
The error body uses the OpenAI shape, so OpenAI SDKs raise it as an exception you can catch:
{"error": {"message": "...", "type": "...", "code": "invalid_api_key", "param": null}}
Every response also carries an X-Request-Id. Keep it in your logs; it's the quickest way for support to find a request.
See the full list in the Model API reference.
Still need help?#
- General support: support@clatterlabs.com or team@clatterlabs.xyz
- Infrastructure questions, or permanent deletion of your data (your whole account or one service): infrastructure@clatterlabs.xyz
We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Related articles
Still need help?
Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.