Troubleshooting · Cline

Cline 401 invalid x-api-key (Anthropic) — Fix

Cline returns 401 invalid x-api-key when the Anthropic-compatible endpoint rejects the key: wrong base URL field, whitespace in the key, or a revoked key. The fix checklist.

What you see

HTTP 401
{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}

Why it happens

  • The custom base URL option is off, so the key is verified against the default endpoint that has never seen it.
  • The key was pasted with leading or trailing whitespace, or truncated.
  • The base URL includes a path suffix, so requests go to a URL the endpoint does not serve.
  • The key was revoked or expired.

How to fix it

  • In Cline's Anthropic provider settings, enable the custom base URL and set it to the origin that issued the key — for this gateway, https://api.apitoken.sale, with no /v1 suffix.
  • Re-paste the key cleanly and confirm it is active in the issuer's dashboard.
  • Verify the pair with curl before returning to Cline.

Cline provider settings

API Provider:  Anthropic
Anthropic API Key:  sk-pool-•••
[x] Use custom base URL:  https://api.apitoken.sale

Related searches

  • cline 401 anthropic
  • cline invalid api key

FAQ

Why does Cline reject a key that works elsewhere?+
If the custom base URL box is unchecked, Cline sends the key to api.anthropic.com. Enable the base URL first, then the same key verifies.
Does the Cline base URL need /v1?+
No — the origin only. Cline's SDK appends API paths itself; a /v1 suffix produces doubled paths and hard-to-read failures.
Which models can I select after the key works?+
The ones the endpoint serves. List them with GET /v1/models against the same base URL and key.

Skip the broken setup

apiToken.sale serves the standard Anthropic API — same models, same SDKs, one prepaid balance. Point your tool's base URL at it, and the config on this page works as written.