Skip to content

Setting Environment Variables for Claude Code in Windows ​


powershell

$env:ANTHROPIC_BASE_URL = "你的 url"
$env:ANTHROPIC_AUTH_TOKEN = "your-key"

Method 2: Command Prompt (CMD) ​

cmd

set ANTHROPIC_BASE_URL=你的 url
set ANTHROPIC_AUTH_TOKEN=your-key

Method 3: Permanent Setup (Using setx command) ​

cmd

setx ANTHROPIC_BASE_URL "你的 url"
setx ANTHROPIC_AUTH_TOKEN "your-key"

Method 4: Graphical Interface Setup ​

  1. Right-click "This PC" → "Properties"
  2. Click "Advanced system settings"
  3. Click "Environment Variables"
  4. Click "New" in "User variables" or "System variables"
  5. Add the two variables separately

Verify Your Setup ​

After setup, you can verify with the following commands:

PowerShell:

powershell

echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_AUTH_TOKEN

CMD:

cmd

echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_AUTH_TOKEN%

Note:

  • Methods 1 and 2 are only valid for the current session
  • Methods 3 and 4 will save permanently
  • After using setx, you need to reopen the command line window for changes to take effect