Clatter LabsHelp Center

What does 401 invalid_api_key mean?

TroubleshootingUpdated

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 Authorization header, or Bearer missing
  • 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#

  1. Print the first few characters of the key your code actually sends; it must start with clsk_.
  2. Check the key still exists in Console › API keys.
  3. 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?#

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.

Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyz
For deleting your whole account or the data of one service.