Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save OctavianTocan/c5ffdf4456f6b337161bb9a6eefd3d7f to your computer and use it in GitHub Desktop.

Select an option

Save OctavianTocan/c5ffdf4456f6b337161bb9a6eefd3d7f to your computer and use it in GitHub Desktop.

Claude Code Multi-Provider Setup for PowerShell

Configure Claude Code to work with multiple LLM providers (DeepSeek, z.ai/GLM, Kimi, OpenRouter) in PowerShell.

Setup Instructions

1. Create/Edit Your PowerShell Profile

Open PowerShell and run:

if (!(Test-Path -Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force
}
notepad $PROFILE

2. Add Provider Functions

Add 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."
}

3. Set Up Secure API Key Storage

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)"

4. Reload Profile

Either restart PowerShell or run:

. $PROFILE

5. Usage

deepseek                      # 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

Notes

  • For OpenRouter support, you need to run y-router locally using Docker
  • All commands support additional flags via the @args parameter
  • The secrets file should be kept secure and not shared
  • Environment variables are cleaned up when switching providers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment