Claude Code
Written for Claude Code 2.1.287 (npm latest), from its documentation. Claude Code speaks the Anthropic Messages API, and zdr.sh serves that API at its origin, so one settings block points the whole client at us.
Anthropic does not support routing Claude Code to non-Claude models through a gateway; the variables below are how the client treats an id it does not recognise.
Settings#
Put this in ~/.claude/settings.json, so the credential is never committed:
json
| Variable | Why it is set |
|---|---|
ANTHROPIC_BASE_URL | The origin only, no /v1: Claude Code appends the path |
ANTHROPIC_AUTH_TOKEN | Sent as a bearer token |
ANTHROPIC_MODEL | The main model; /model and --model override it per session |
ANTHROPIC_DEFAULT_OPUS_MODEL | What the Opus alias resolves to |
ANTHROPIC_DEFAULT_SONNET_MODEL | What the Sonnet alias resolves to |
ANTHROPIC_DEFAULT_HAIKU_MODEL | What the Haiku alias resolves to; also the model for background tasks |
CLAUDE_CODE_SUBAGENT_MODEL | The model subagents run on |
CLAUDE_CODE_MAX_CONTEXT_TOKENS | The window for an unknown id, which defaults to 200K |
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC | Turns off auto-updates, telemetry, error reporting and feature fetching |
The mapping is an example: any zdr.sh id fits any alias. Models has the ids and their windows.
Things to know#
- Credential.
ANTHROPIC_AUTH_TOKENis the reliable one.ANTHROPIC_API_KEYis sent asx-api-keyand needs a one-time approval in interactive mode. zdr.sh accepts either header. - Claude model ids. A Messages request for a
claude-id is served by the model the key maps that family to. The mapping is in the key's settings in the dashboard; with it off, the request is refused with a 404 that says so. - An existing claude.ai login is not replaced by the base URL alone. Always set a zdr.sh credential as well.
- Context. An unresolved id is assumed to have a 200K window, so
CLAUDE_CODE_MAX_CONTEXT_TOKENS=1048576is what lets a long session use the full window. - Output. For an unresolved id the output cap defaults to 32,000 and is capped at 128,000; set
CLAUDE_CODE_MAX_OUTPUT_TOKENSup to 128000 for the models that allow more. - Token counting. zdr.sh serves
/v1/messages/count_tokens, so Claude Code uses real counts. - Thinking. Requests carry adaptive thinking and effort, and reasoning comes back as thinking blocks.
- Rotating keys in fleets.
apiKeyHelpercan print a fresh key; its output is cached for five minutes and the helper re-runs on a 401 or 403. /statusshows the base URL and where the credential came from, which is the quickest way to confirm the setup.