Skip to main content

首页 / Posts

[Claude Code] Bypass Forced VS Code Login and Route to Other Models

A step-by-step guide to bypassing the Claude Code extension login check and routing the plugin through Claude Code Router so it can connect to large-model services of your choice.

Rosetears·
··590 words·3 mins

Introduction
#

After the 2.0 update, the Claude Code extension introduced mandatory login verification, preventing users from calling models through a local router without logging in.

This tutorial shows how to bypass that local login check and route the Claude extension through Claude Code Router (CCR) to any large-model service you choose.


Install the Claude extension and CLI tools
#

First install Visual Studio Code. If needed, see the VS Code beginner guide: VS Code installation and configuration. Then open the Extensions panel in VS Code, search for Claude Code for Vs Code, and install it.


Bypass Claude login verification
#

The extension only checks a local configuration file. We can create that file and make the extension think you are already logged in.

Create a file named config.json in:

  • Windows: %UserProfile%\.claude\
  • macOS / Linux: ~/.claude/

Put any string in primaryApiKey, for example hello-claude. This field only passes the local status check. Restart VS Code after creating the file, and the extension should stop forcing login.


Install and configure Claude Code Router (CCR)
#

CCR forwards Claude extension requests to your configured model service.

  1. Install CCR with npm.
  2. Run ccr start once to generate the default config file, then stop it with Ctrl+C.
  3. Open %UserProfile%\.claude-code-router\config.json on Windows or ~/.claude-code-router/config.json on macOS/Linux.
  4. Fill the APIKEY field with a custom local key such as sk-ant-local-ccr-1234567890.
  5. Run ccr ui, click Add service, and configure the large model and real API key you want to use.

If you are unsure how to configure OpenAI, Gemini, Qwen, or other providers, see Claude Code Router: connect five major models.


Point Claude to CCR
#

Tell the Claude extension not to call the official API, but your local CCR service instead.

Step 1: configure VS Code extension environment variables
#

Open VS Code settings, find Claude Code: Environment Variables, edit settings.json, and add ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY pointing to your local CCR service and local token.

Reload the VS Code window after saving.

Step 2: system-level environment variables
#

On Windows, use administrator PowerShell and set ANTHROPIC_BASE_URL plus ANTHROPIC_AUTH_TOKEN with setx. Also set $env: values for the current terminal if you want immediate effect.

On macOS/Linux, append export ANTHROPIC_BASE_URL="http://[redacted-ip]:3456" and export ANTHROPIC_AUTH_TOKEN="sk-ant-local-ccr-1234567890" to your shell config, then source it.

Alternative: .claude/settings.json
#

An older method is to set environment variables inside .claude/settings.json, but recent tests suggest it sometimes does not take effect after plugin updates. Keep it only as an archival fallback and prefer the two methods above.


Common issue: API ERROR
#

Try the following order:

  1. Confirm environment variables and VS Code settings.json both point to CCR.
  2. In the VS Code terminal, run ccr code and check whether CCR works.
  3. Run claude directly for a test.
  4. Finally use the extension.

If this post helped, you can support Rosetears on Afdian.

Screenshots and media
#

插件设置
在settingsjson中编辑

Preserved command, configuration, and prompt blocks
#

1
2
3
{
  "primaryApiKey": "any-string-is-ok-here"
}
1
npm install -g @musistudio/claude-code-router
1
ccr start
1
2
3
{
  "APIKEY": "sk-ant-local-ccr-1234567890"
}
1
ccr ui
1
2
3
4
5
6
{
  "claudeCode.environmentVariables": [
    { "name": "ANTHROPIC_BASE_URL", "value": "http://[redacted-ip]:3456" },
    { "name": "ANTHROPIC_API_KEY", "value": "sk-ant-local-ccr-1234567890" }
  ]
}
1
2
3
4
5
6
setx ANTHROPIC_BASE_URL "http://[redacted-ip]:3456"
setx ANTHROPIC_AUTH_TOKEN "sk-ant-local-ccr-1234567890"

# 当前窗口立即生效(可选)
$env:ANTHROPIC_BASE_URL="http://[redacted-ip]:3456"
$env:ANTHROPIC_AUTH_TOKEN="sk-ant-local-ccr-1234567890"
1
2
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN
1
2
3
4
echo 'export ANTHROPIC_BASE_URL="http://[redacted-ip]:3456"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-ant-local-ccr-1234567890"' >> ~/.zshrc

source ~/.zshrc  # 立即生效
1
2
echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN
1
2
3
4
5
6
7
{
  "env": {
    "ANTHROPIC_BASE_URL": "http://[redacted-ip]:3456",
    // 这里用 AUTH_TOKEN 或 API_KEY 都可以,挑一个顺眼的就行
    "ANTHROPIC_AUTH_TOKEN": "sk-ant-local-ccr-1234567890"
  }
}

Related tools

Related