Configure Claude Code to work with multiple LLM providers (DeepSeek, z.ai/GLM, Kimi, OpenRouter) in PowerShell.
Open PowerShell and run:
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
notepad $PROFILEAdd these functions to your PowerShell profile:
# === CLAUDE CODE MULTI-PROVIDER SWITCHER ===
# --- DeepSeek Configuration ---
function deepseek {
$env:ANTHROPIC_BASE_URL = "https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = $env:DEEPSEEK_API_KEY
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "deepseek-reasoner"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek-chat"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = 1
claude @args
}
# --- z.ai (GLM) Configuration ---
function glm {
$env:ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = $env:Z_AI_API_KEY
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "glm-4.5-air"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "glm-4.6"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "glm-4.6"
claude @args
}
# --- Kimi (Moonshot AI) Configuration ---
function kimi {
$env:ANTHROPIC_BASE_URL = "https://api.moonshot.ai/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = $env:KIMI_API_KEY
claude @args
}
# --- OpenRouter Configuration ---
function openrouter {
$env:ANTHROPIC_BASE_URL = "http://localhost:8787"
$env:ANTHROPIC_API_KEY = $env:OPENROUTER_API_KEY
$env:ANTHROPIC_CUSTOM_HEADERS = "x-api-key: $env:ANTHROPIC_API_KEY"
claude @args
}
# --- Reset to Default ---
function claude_reset {
Remove-Item env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
Remove-Item env:ANTHROPIC_AUTH_TOKEN -ErrorAction SilentlyContinue
Remove-Item env:ANTHROPIC_API_KEY -ErrorAction SilentlyContinue
Remove-Item env:ANTHROPIC_CUSTOM_HEADERS -ErrorAction SilentlyContinue
Remove-Item env:ANTHROPIC_MODEL -ErrorAction SilentlyContinue
Remove-Item env:ANTHROPIC_SMALL_FAST_MODEL -ErrorAction SilentlyContinue
Write-Host "Claude environment has been reset to default."
}Add this to your PowerShell profile:
# Load API keys from secure file
$secretsFile = "$env:USERPROFILE\.claude-secrets.ps1"
if (Test-Path $secretsFile) {
. $secretsFile
}Create %USERPROFILE%\.claude-secrets.ps1:
$env:DEEPSEEK_API_KEY = "your_deepseek_api_key_here"
$env:Z_AI_API_KEY = "your_z_ai_api_key_here"
$env:KIMI_API_KEY = "your_kimi_api_key_here"
$env:OPENROUTER_API_KEY = "your_openrouter_api_key_here"Secure the secrets file:
icacls "$env:USERPROFILE\.claude-secrets.ps1" /inheritance:r /grant:r "$env:USERNAME:(F)"Either restart PowerShell or run:
. $PROFILEdeepseek # Start Claude Code with DeepSeek
glm # Start with GLM
kimi # Start with Kimi
openrouter # Start with OpenRouter (requires Docker)
deepseek -m "deepseek-coder" # With specific model
claude_reset # Reset to default- For OpenRouter support, you need to run y-router locally using Docker
- All commands support additional flags via the
@argsparameter - The secrets file should be kept secure and not shared
- Environment variables are cleaned up when switching providers