AiRouter Docs

Configure API Access

How to configure Claude Code to use AiRouter's API endpoint and key

⚙️ Configure API Access

After installation, you need to configure Claude Code to use AiRouter's API endpoint and key. There are two methods — choose either one.

# PowerShell (temporary, resets when window closes)
$env:ANTHROPIC_BASE_URL = "https://airouter.one"
$env:ANTHROPIC_API_KEY = "sk-your-api-key"

# Permanent (recommended):
# 1. Press Win+R, type sysdm.cpl, press Enter
# 2. Click "Advanced" → "Environment Variables"
# 3. Create new "User variables":
#    Variable name: ANTHROPIC_BASE_URL  Value: https://airouter.one
#    Variable name: ANTHROPIC_API_KEY   Value: sk-your-api-key
# 4. Click OK to save, then restart your terminal
# Add to ~/.zshrc (permanent)
echo 'export ANTHROPIC_BASE_URL="https://airouter.one"' >> ~/.zshrc
echo 'export ANTHROPIC_API_KEY="sk-your-api-key"' >> ~/.zshrc

# Apply changes immediately
source ~/.zshrc
# Add to ~/.bashrc (permanent)
echo 'export ANTHROPIC_BASE_URL="https://airouter.one"' >> ~/.bashrc
echo 'export ANTHROPIC_API_KEY="sk-your-api-key"' >> ~/.bashrc

# Apply changes immediately
source ~/.bashrc

⚠️ Replace sk-your-api-key with the actual API Key you created in the AiRouter console.

Method 2: Modify settings.json

If you prefer not to set environment variables, you can directly modify Claude Code's configuration file:

# Configuration file path:
# %USERPROFILE%\.claude\settings.json

# Open with Notepad or VSCode and add:
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://airouter.one",
    "ANTHROPIC_API_KEY": "sk-your-api-key"
  }
}
# Configuration file path:
# ~/.claude/settings.json

# Create or edit the file:
mkdir -p ~/.claude
cat > ~/.claude/settings.json << 'EOF'
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://airouter.one",
    "ANTHROPIC_API_KEY": "sk-your-api-key"
  }
}
EOF

💡 settings.json takes priority over environment variables. If both are set, the values in settings.json will be used.

Verify Configuration

After configuration, run the following in your terminal:

claude

If you see the Claude Code interactive interface, the configuration was successful.

On this page