401 invalid_api_key.

Updated November 23, 2026.

If an UncensoredLLM request returns 401 invalid_api_key, find out which credential your client actually sends to https://api.uncensoredllm.ai/v1 before anything else, then confirm it is the active key you meant to use. Keep the test request plain, with a catalog id such as glm-5.3-uncensored; changing the model id does not repair a missing or wrong key.

Get a key

What the code covers

The API documents four causes for this code: no key at all, a key placed in the URL instead of a header, a string that is not a key, and a key that was revoked. Other account states have their own codes. An empty balance is 402 insufficient_balance and a key limited to other models gets 403 scope_denied, so a 401 is always about the credential itself.

Work down this list

  1. Is the variable set where the client runs? A key exported in one terminal is not visible to a service, a container or an IDE run configuration. Check it in the same environment, without printing it:
shell
1python3 -c 'import os; k = os.environ.get("UNCENSOREDLLM_API_KEY", ""); print("set" if k else "missing", "length", len(k), "live-key prefix:", k.startswith("sk-ullm-live-"))'
  1. Is that the variable the client reads? Code that builds the client without an explicit api_key falls back to the SDK’s default variable, often OPENAI_API_KEY, which may still hold a key for a different service.
  2. Is it in a header? The key travels as Authorization: Bearer (OpenAI SDKs) or x-api-key (Anthropic SDK). A key appended to the URL as a query parameter is refused.
  3. Is the key still active? Open the keys page in the console. A revoked key keeps failing; create a new one and replace it everywhere the old one was stored.
  4. Does the key work on its own? List the models it can call. No model runs, and the status code alone answers the question: 200 accepted, 401 not.
shell
1curl -s -o /dev/null -w "%{http_code}\n" "https://api.uncensoredllm.ai/v1/models" \
2 -H "Authorization: Bearer $UNCENSOREDLLM_API_KEY"

If that prints 200 and your app still gets 401, the key is fine and the app is sending something else: go back to step 2. A base URL on the website host instead of the API host can cause the same symptom, because the site forwards API paths with a redirect that many HTTP clients follow without the Authorization header; the base URL page shows how to read the final URL.

Invalid key: questions

Why can the public catalog load while my chat request returns 401?

GET /v1/catalog takes no key at all, so it loads for anyone and says nothing about your credential. The chat route checks the key before anything else. Use GET /v1/models with your key instead: it needs a valid key and runs no model.

How do I check which environment variable the client reads without printing the key?

Print whether the variable is set, its length and whether it starts with sk-ullm-live-, and nothing of the key itself. Then check the client: the OpenAI SDKs fall back to OPENAI_API_KEY when no api_key is passed, so a leftover key from another service can be the one sent instead of UNCENSOREDLLM_API_KEY.

Does switching models fix an invalid API key?

No. The key is judged before the model, so every id returns the same 401 until the credential is fixed. Model problems arrive as different codes: 404 model_not_found for an unknown id, 403 scope_denied when the key is limited to other models. See model not found.

Read next

Join on TelegramHelp