Claude Code fails in three ways when you point it at a relay, and each one points at a different layer.
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.
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.
Not network, not key format. The account or key lacks that model. Verify against what the relay reports.
1. curl /v1/models — is the endpoint reachable with this key? 2. curl /v1/messages — does the Anthropic path work? 3. 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.
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.
*Setup notes: kuku-momo.github.io/claude-pojia · Config generator: pip install ttapi-relay-switch*