Skip to content

Setting up Claude Code

Claude Code talks to Nexus over Anthropic Messages. One Nexus key is enough. Put it in a separate environment so the default Claude login stays unchanged.

The shared order is on Client setup.

Values

Field Value
Base URL https://api.nexus-hub.tech
Protocol Anthropic Messages
Route POST /v1/messages
Key variable ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY
Version header anthropic-version: 2023-06-01

Do not add /v1 to the base URL. Claude Code appends /v1/messages. ANTHROPIC_AUTH_TOKEN is sent as Authorization: Bearer. ANTHROPIC_API_KEY is sent as x-api-key. Set one of them for this entry, not both.

First check in the shell

export ANTHROPIC_BASE_URL="https://api.nexus-hub.tech"
export ANTHROPIC_AUTH_TOKEN="your_nexus_key"

Start Claude Code in that shell and send a short prompt. Run /status. It should show this base URL and that the key comes from ANTHROPIC_AUTH_TOKEN.

Keep it for later

When the short check works, put the same variables in ~/.claude/settings.json. That file applies to every project. On Windows the path is %USERPROFILE%\.claude\settings.json.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.nexus-hub.tech",
    "ANTHROPIC_AUTH_TOKEN": "your_nexus_key"
  }
}

Do not put the key in a project's .claude/settings.json. That file is shared with the repository. A value in the settings env block wins over a shell export of the same name.

If you use ANTHROPIC_API_KEY instead, omit ANTHROPIC_AUTH_TOKEN.

Model

Pick an id from GET /v1/models for this key. Claude Code can read that list from Nexus and show it in /model.

Set ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, or ANTHROPIC_DEFAULT_HAIKU_MODEL only to an exact id from that list. Leave them unset when /model is enough.

Check

Send a short message. A normal reply means the connection works. Token counting uses POST /v1/messages/count_tokens and needs the same base URL and version header.

If it does not work

  • 401 or invalid_key: one key, no extra spaces, and no Bearer prefix inside the variable.
  • model_not_found or model_not_allowed: the id is not in this key's GET /v1/models list.
  • unsupported_model: the id is visible, but not allowed on Messages. Pick another id.
  • Wrong address: the base is https://api.nexus-hub.tech with no /v1.
  • A shell export seems ignored: the settings env block is the value in effect.

Send support the route, error code, time, and x-request-id. Do not send the key or a full prompt.

Official reference: Connect Claude Code to an LLM gateway.