Why does my Unlid API key return 401 invalid_api_key?

The key the request carried is missing, mistyped, revoked, or the request did not go to Unlid at all. Unlid keys start with ul- and are sent as Authorization: Bearer ul-…; if the error says "Incorrect API key provided … platform.openai.com", your app sent the key to OpenAI because its base URL is not set to Unlid.

Check, in this order

  1. Base URL. It must be https://api.unlid.ai/v1, with nothing after /v1 (Claude Code takes https://api.unlid.ai without /v1). An error that mentions platform.openai.com came from OpenAI, not from Unlid.
  2. The key itself. Copy it again without spaces or line breaks. The full key is shown only once, when it is created; the account page shows just its prefix. If you lost it, create a new one.
  3. Revoked or regenerated. A key that worked minutes ago and now fails was usually revoked or replaced on the account page. Update every app that uses it.
  4. Header. OpenAI-style requests send Authorization: Bearer ul-…; Anthropic-style requests may send x-api-key: ul-….

Test the key on its own

curl https://api.unlid.ai/v1/models -H "Authorization: Bearer ul-…"

If this returns the model list, the key works and the problem is in the app's settings: see its page under Apps & clients. A 401 is never charged.

Not the same as

403 means the key works but is not allowed this model or the account is restricted; 402 means the balance cannot cover the request (402 answer).

Related questions

Something not covered? Ask in the support chat at the bottom right, or see the FAQ and the API docs.