Troubleshooting · Zed

Zed Claude 401 invalid x-api-key — Anthropic Settings Fix

Zed's assistant passes the Anthropic 401 invalid x-api-key through verbatim. Where the key and api_url live in Zed settings and why they must come from the same issuer.

What you see

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

Why it happens

  • The key in Zed's Anthropic provider settings and the api_url point at different issuers — a gateway key sent to the default endpoint, or vice versa.
  • The key was pasted with whitespace or truncated.
  • A custom api_url was set with a /v1 suffix, so requests hit a doubled path and fail before or instead of auth.
  • The key was revoked or expired.

How to fix it

  • Set language_models.anthropic.api_url to the origin that issued the key, and paste that issuer's key in the provider settings.
  • Keep the api_url to the origin only — Zed appends /v1 paths itself.
  • Verify the exact pair with curl before changing anything else.

Zed settings.json for this gateway

{
  "language_models": {
    "anthropic": {
      "api_url": "https://api.apitoken.sale"
    }
  }
}

Related searches

  • zed anthropic api key not working
  • zed claude 401

FAQ

Where does Zed keep the Anthropic base URL?+
In settings.json under language_models.anthropic.api_url. The API key itself is entered in the assistant's provider configuration.
Why does my key fail in Zed but work in curl?+
Zed sends it to whatever api_url is configured. If that differs from the URL you curl — including a stray /v1 — the endpoint seeing the key is not the one that issued it.
Do I need an Anthropic account to use Claude in Zed?+
No — any Anthropic-compatible endpoint works: set api_url to the issuer and use its 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.