Claude Code access

Set the gateway address, site key, and available Claude models.

Claude Code connects to this site through the Anthropic Messages protocol. It is recommended to verify the connection in the terminal before configuring the VS Code extension and use the actual model ID that supports Messages and tool calls.

Preparation before starting

  • Create a separate key for Claude Code at API Key.
  • In Models and Prices, confirm that the model supports Messages and tool calls, and then use the current key to query available models.
  • Press Official Installation Instructions to install Claude Code suitable for the current operating system.

After installation, run the following commands to confirm that the CLI is available and check the environment:

claude --version
claude doctor

This site’s key is used for the gateway API and is calculated separately from Claude’s official subscription, and does not include official subscription rights.

Step one: Set terminal connection information

macOS, Linux, WSL: Bash or zsh

First hide and enter the site key, and then set the address and model:

printf 'API Key: '
read -rs DUNDUN_API_KEY
printf '\n'
export DUNDUN_API_KEY
export ANTHROPIC_BASE_URL="https://dunduntoken.com"
export ANTHROPIC_AUTH_TOKEN="$DUNDUN_API_KEY"
unset ANTHROPIC_API_KEY
export ANTHROPIC_MODEL="CLAUDE_MODEL_ID"
claude

Windows PowerShell

$credential = Get-Credential -UserName "api" -Message "在密码栏填写本站 API Key"
$env:ANTHROPIC_AUTH_TOKEN = $credential.GetNetworkCredential().Password
Remove-Variable credential
$env:ANTHROPIC_BASE_URL = "https://dunduntoken.com"
Remove-Item Env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
$env:ANTHROPIC_MODEL = "CLAUDE_MODEL_ID"
claude
Configuration Fill in instructions
ANTHROPIC_BASE_URL Fill in the site root address without /v1 or /messages
ANTHROPIC_AUTH_TOKEN API Key created by this site
ANTHROPIC_MODEL Replace CLAUDE_MODEL_ID with the actual available model ID

The client will splice /v1/messages. The above operations only modify the current terminal environment; clearing ANTHROPIC_API_KEY is to avoid mixing it with the gateway token. Please restore the original settings when switching back to the original configuration.

Step 2: Verify terminal session

  1. Enter /status in the new session to view the client connection information.
  2. Send “Reply OK only” and observe whether you receive a normal reply.
  3. Open the Call Record of this site and check the time, model, status and usage.
  4. In the test project, a file is required to be read, and then multiple rounds of dialogue and actual tool calls are tested.

The actual routing is based on the call record, and the model’s self-reported name cannot be used to confirm the connection. After modifying the environment variables, exit the old process and create a new session.

Step 3: Configure VS Code extension

Install official extension

Search for Claude Code in the VS Code extension store, confirm that the publisher is Anthropic, the extension identifier is anthropic.claude-code, and then install or enable it. When you need to restart the extension, complete the restart first.

Open user-level environment settings

Open the extension settings, find Claude Code: Environment Variables, and choose to edit in settings.json. Preferences: Open User Settings (JSON) can also be run from the command panel.

Merge the following configuration into the outermost object of user settings. When there is already claudeCode.environmentVariables, update the corresponding item and do not define the same setting repeatedly:

{
  "claudeCode.environmentVariables": [
    {
      "name": "ANTHROPIC_BASE_URL",
      "value": "https://dunduntoken.com"
    },
    {
      "name": "ANTHROPIC_AUTH_TOKEN",
      "value": "YOUR_DUNDUN_API_KEY"
    },
    {
      "name": "ANTHROPIC_MODEL",
      "value": "CLAUDE_MODEL_ID"
    }
  ]
}

Replace key and model placeholders, preserving other user settings. This method will store the key in the local settings. Please make sure you are editing user settings and check the setting synchronization range; do not put the real key into the project’s .vscode/settings.json. When the extension inherits the old ANTHROPIC_API_KEY from the process environment, it also needs to clean up the source of the conflict and restart.

Reload and verify

  1. Save the settings and execute Developer: Reload Window.
  2. Open the Claude Code panel, create a new session and send a short message.
  3. Call the record on this site to confirm this request.
  4. Request to read the test project file and continue according to the client’s normal permission confirmation process.

Extensions may run in a remote environment via remote SSH, WSL or Dev Container. The settings and variables read by the actual extension host should be checked; simply setting variables in the local terminal may have no effect.

Configure model gears as needed

When you need to specify the default models of Haiku, Sonnet, and Opus respectively, set the corresponding variables in the terminal, or add the same name to the extended environment variable array:

export ANTHROPIC_DEFAULT_HAIKU_MODEL="HAIKU_MODEL_ID"
export ANTHROPIC_DEFAULT_SONNET_MODEL="SONNET_MODEL_ID"
export ANTHROPIC_DEFAULT_OPUS_MODEL="OPUS_MODEL_ID"

Each placeholder needs to be replaced with a model ID that is actually available for the current key. Basic access does not require configuring all gears; only set the corresponding gears when you are ready to use them, and check the request records after switching.

FAQ

Phenomenon Troubleshooting steps
401 or duplicate authentication prompt Check gateway token, expired key and old ANTHROPIC_API_KEY source
404 Base URL should be root address; check model ID and Messages support
Terminal successful, extension failed Check the overlay relationship between extended environment variables, user settings and workspace settings, and then reload the window
Still use the original service after changing the configuration Exit the old session and process, check the settings file and startup environment for overrides
The chat was successful, but the tool call failed Check the model tool capabilities, context length, and parameters in the failed request
Prompt to log in Check whether the gateway address and valid credentials are provided at the same time; hiding the prompt cannot replace configuring authentication

Continue reading

Anthropic Messages · CC-Switch · Error Troubleshooting

Configuration basis: Claude Code gateway description, VS Code extension description.