Claude Code fails in three ways when you point it at a relay, and each one points at a different layer.
404 — the base URL is wrong
POST /v1/v1/messages -> 404
Claude Code appends /v1/messages itself. If your base already ends in /v1, you get the doubled path.
export ANTHROPIC_BASE_URL="https://your-relay.example"
export ANTHROPIC_AUTH_TOKEN="sk-..."
This is the opposite of OpenAI-compatible clients, where the base must include /v1. People switch between Claude Code and Codex and carry the wrong convention across. That single suffix is behind most 404s I have seen.
401 — the auth header, not your balance
Anthropic wire format uses x-api-key. OpenAI uses Authorization: Bearer. A relay that accepts both still expects the matching header per protocol.
curl -s https://your-relay.example/v1/messages \
-H "x-api-key: $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"<model>","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'
If that works but Claude Code does not, the header name is the difference.
403 — the model is not enabled
Not network, not key format. The account or key lacks that model. Verify against what the relay reports.
The order to debug in
-
curl /v1/models— is the endpoint reachable with this key? -
curl /v1/messages— does the Anthropic path work? - Claude Code — only now look at the client.
Two minutes in this order. The reverse order (start with the client, change settings randomly) takes an afternoon and ends with a working config nobody understands.
One thing nobody mentions
Claude Code fires several requests in parallel. A relay that handles single requests fine can still throw 429 under real usage. If curl works but Claude Code shows rate errors, that is concurrency, not configuration.
Top comments (0)