OpenRouter 401 errors: what each message means and how to fix it
"No cookie auth credentials found", "User not found." and OpenRouter's other 401s each mean one thing. The cause behind each, and how to test a key.
OpenRouter’s 401 wording tells you which way the key went wrong. “No cookie auth credentials found” means no key was sent at all. “No API key in the Authorization header” means the variable holding it was empty or unset. “Invalid API key: this is not an OpenRouter API key” means another company’s key was sent. “User not found.” means a key in OpenRouter’s format that OpenRouter does not know. “Missing Authentication header” means a credential in a form it does not read, or none, on an endpoint that never takes a browser session. Check the key with GET /api/v1/key, not by listing models, which answers even with a bad key.
Each message and its cause
As of November 2026, OpenRouter returns these, each with HTTP 401 and an error body of the form {"error":{"message":"…","code":401}}:
- “No cookie auth credentials found”: the request had no
Authorizationheader. Endpoints such as/api/v1/chat/completionsalso accept a signed-in session, which is where the cookie comes in; the message means neither a key nor a session arrived. Your agent is not configured with a key for OpenRouter, or is configured for it under a provider entry it is not using. - “No API key in the Authorization header: expected "Bearer sk-or-...". Check that your OpenRouter API key environment variable is set”: the header was there but held nothing usable, such as
Bearerfollowed by nothing,undefinedornull, or a key without the wordBearer. Those are what a program sends when the variable it reads the key from is empty or not set. - “Invalid API key: this is not an OpenRouter API key”: the key does not start with
sk-or-. The full message goes on to say that an OpenAI or Anthropic SDK may be picking upOPENAI_API_KEYorANTHROPIC_API_KEYinstead of the OpenRouter key, which is the usual way it happens. - “User not found.”: the key has OpenRouter’s prefix, but OpenRouter has no such key. It was deleted or disabled, mistyped, or cut short when pasted. OpenRouter’s authentication page lists a bare “Invalid API key” for the same cases, and “API key expired” for a key past an expiry date set on it.
- “Missing Authentication header”: a credential in another scheme, such as
Basic, or no credential on an endpoint that does not take a session. It also appears in agents’ reports where the stored key was not the OpenRouter key at all: one OpenClaw thread traced it to an Anthropic token saved as the OpenRouter key, and another reporter to a key saved without itssk-or-prefix.
An OpenRouter key is sk-or-v1- followed by 64 lowercase hexadecimal characters, 73 characters in all, and is sent as Authorization: Bearer <key> with no extra whitespace or quotes.
Listing models does not prove the key
As of November 2026, GET /api/v1/models answers with the full list even when the key is unknown or malformed. An agent that fills its model picker from OpenRouter and then fails on the first message has shown only that it can reach OpenRouter. The check that does test the key is the current-key endpoint, run in the same environment the agent runs in:
curl https://openrouter.ai/api/v1/key \
-H "Authorization: Bearer $OPENROUTER_API_KEY"CopiedA working key returns its label, limit, usage and limit_remaining; a broken one returns one of the 401s above, and the wording says which kind of broken. The label is worth reading even on success: if it names a key you meant to retire, the agent is reading a different key from the one you set. Two checks that never print the key itself:
echo "${OPENROUTER_API_KEY:0:9}" # should print sk-or-v1-
echo -n "$OPENROUTER_API_KEY" | wc -c # should print 73CopiedOn a server: the key you set is not the key the agent sees
An agent that works in your terminal and fails as a service is usually reading a different environment. Three ways that happens:
The variable never reaches the service. A key exported in ~/.bashrc or typed into a shell exists for that shell and what it starts. A systemd service is not started from your shell, and systemd’s documentation says processes started by the system service manager generally do not inherit environment variables. The key has to be given to the unit with Environment= or EnvironmentFile=, and the service restarted. Until it is, the variable the agent reads is empty, which gives the first or second message above depending on whether the agent still sends a header.
The .env file is not the one being read. An .env beside a project is read only by a program that loads it. systemd’s EnvironmentFile= takes plain NAME=value lines and does not look for .env on its own, and Docker Compose uses a project’s .env to fill in the compose file, not to set variables inside the container (the difference is covered in Compose’s .env versus env_file).
An older key in another place wins. Agents read keys from several places, an environment variable, a .env, their own saved credentials, and which one wins is the agent’s rule, not necessarily the one you just set. In a Hermes report, an old key in the wrong format in .env was used ahead of a good key saved with the agent’s own login, giving “Missing Authentication header” until it was removed. In the OpenClaw thread above, setup kept the value already saved in the agent’s auth profile file instead of asking for a new one, so the saved entry had to be deleted first. When a fresh key changes nothing, search for the variable name across the agent’s config and the service’s environment, and remove every copy but one.