MISSING_API_KEY: Authorization header must be: Bearer <api_key>
{
"error": {
"type": "unauthorized",
"code": "MISSING_API_KEY",
"message": "Authorization header must be: Bearer <api_key>"
}
}
This is a request shape problem, not a credential problem. The gateway never got as far as checking whether your key is valid.
Three ways to trigger it
-
No
Authorizationheader at all. Most common when a proxy or SDK strips unknown headers, or when the header was set on the wrong request object. -
A header that is not
Bearer <something>.Authorization: sk-abc…without theBearerprefix fails here. So doesBasic. -
Bearerwith nothing after it. This one has its own message — “Authorization header is empty after Bearer” — and usually means a template rendered an empty variable:# $GENACE_API_KEY was unset curl -H "Authorization: Bearer $GENACE_API_KEY" …Worth checking first, because it looks identical to a correct request in most logs.
The correct shape
curl https://genace.ai/api/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
Not the same as INVALID_API_KEY
| MISSING_API_KEY | INVALID_API_KEY | |
|---|---|---|
| Header present and well-formed | no | yes |
| What to check | how you are sending it | the key itself |
If you are getting INVALID_API_KEY, the header is fine and the key is the
problem — see INVALID_API_KEY.
Where these facts come from
- codebase: src/ai/api/auth.ts — header parsing and the two MISSING_API_KEY throws