A powerful Claude Code model switching tool with support for multiple AI service providers and intelligent fallback mechanisms
Want to try immediately without any API key? Start in 3 steps:
# 1. Install
curl -fsSL https://raw.githubusercontent.com/foreveryh/claude-code-switch/main/quick-install.sh | bash
# 2. Reload shell
source ~/.zshrc # or source ~/.bashrc for bash
# 3. Try it (no keys needed!)
ccm glm # Switch to GLM-4.6
ccc deepseek # Launch Claude Code with DeepSeek⨠That's it! You now have a working Claude Code setup with:
- β Built-in experience keys (via PPINFRA)
- β Zero configuration required
- β Multiple model support
- β Add your own API keys later for unlimited usage
- π€ Multi-model Support: Claude, Deepseek, KIMI, GLM, Qwen and other mainstream AI models
- π Smart Fallback Mechanism: Official API priority with automatic fallback to PPINFRA backup service
- β‘ Quick Switching: One-click switching between different AI models to boost productivity
- π One-Command Launch:
ccccommand switches model and launches Claude Code in a single step - π¨ Colorful Interface: Intuitive command-line interface with clear switching status display
- π‘οΈ Secure Configuration: Independent configuration file for API key management
- π Status Monitoring: Real-time display of current model configuration and key status
| Model | Official Support | Fallback Support(PPINFRA) | Features |
|---|---|---|---|
| π KIMI2 | β kimi-k2-turbo-preview | β kimi-k2-turbo-preview | Long text processing |
| π€ Deepseek | β deepseek-chat | β deepseek/deepseek-v3.2-exp | Cost-effective reasoning |
| π± LongCat | β LongCat-Flash-Chat | β Official only | High-speed chat |
| π― MiniMax M2 | β MiniMax-M2 | β minimax/minimax-m2 | Code & reasoning |
| π StreamLake (KAT) | β KAT-Coder | β Official only | StreamLake AI |
| πͺ Qwen | β qwen3-max (Alibaba DashScope) | β qwen3-next-80b-a3b-thinking | Alibaba Cloud official |
| π¨π³ GLM4.6 | β glm-4.6 | β zai-org/glm-4.6 | Zhipu AI |
| π§ Claude Sonnet 4.5 | β claude-sonnet-4-5-20250929 | β Official only | Balanced performance |
| π Claude Opus 4.1 | β claude-opus-4-1-20250805 | β Official only | |
| π· Claude Haiku 4.5 | β claude-haiku-4-5 | β Official only |
π GLM-4.6 Official Registration
Get started with Zhipu AI's official Claude Code integration:
- Registration Link: https://www.bigmodel.cn/claude-code?ic=5XMIOZPPXB
- Invitation Code:
5XMIOZPPXBGLM-4.6 supports official Claude Code integration with zero-configuration experience. No API key needed to get started!
π° PPINFRA Fallback Service Registration
Get Β₯15 voucher when registering PPINFRA service:
- Registration Link: https://ppio.com/user/register?invited_by=ZQRQZZ
- Invitation Code:
ZQRQZZPPINFRA provides reliable fallback service for Deepseek, KIMI, Qwen, and GLM models when official APIs are unavailable.
One-command installation from GitHub - no cloning required:
curl -fsSL https://raw.githubusercontent.com/foreveryh/claude-code-switch/main/quick-install.sh | bash
source ~/.zshrc # reload shellFeatures:
- β No cloning needed
- β Automatic file download from GitHub
- β Retry mechanism for network failures
- β File integrity verification
- β Progress feedback and error handling
Clone the repository and install locally:
git clone https://github.com/foreveryh/claude-code-switch.git
cd claude-code-switch
chmod +x install.sh ccm.sh
./install.sh
source ~/.zshrc # reload shellWithout installation (run from cloned directory):
./ccc deepseek # Launch with DeepSeek (current process only)
eval "$(./ccm env deepseek)" # Set env vars in current shell onlyThe installation process:
- Copies
ccm.shto~/.local/share/ccm/ccm.sh - Copies language files to
~/.local/share/ccm/lang/ - Injects
ccm()andccc()shell functions into your rc file (~/.zshrc or ~/.bashrc) - Creates
~/.ccm_configon first use (if it doesn't exist)
Does NOT:
- Modify system files
- Change your PATH
- Require sudo/root access
- Affect other shell configurations
CCM uses a hierarchical configuration system:
-
Environment Variables (Highest Priority)
export DEEPSEEK_API_KEY=sk-your-key export KIMI_API_KEY=your-key export GLM_API_KEY=your-key export QWEN_API_KEY=your-key
-
Configuration File
~/.ccm_config(Fallback)ccm config # Opens config in your editor # Or edit manually: vim ~/.ccm_config
# CCM Configuration File
# Note: Environment variables take priority over this file
# Official API keys
DEEPSEEK_API_KEY=sk-your-deepseek-api-key
KIMI_API_KEY=your-moonshot-api-key
LONGCAT_API_KEY=your-longcat-api-key
MINIMAX_API_KEY=your-minimax-api-key
GLM_API_KEY=your-glm-api-key
QWEN_API_KEY=your-qwen-api-key # Alibaba Cloud DashScope
# Optional: override model IDs (if omitted, defaults are used)
DEEPSEEK_MODEL=deepseek-chat
KIMI_MODEL=kimi-k2-turbo-preview
LONGCAT_MODEL=LongCat-Flash-Thinking
MINIMAX_MODEL=MiniMax-M2
QWEN_MODEL=qwen3-max
GLM_MODEL=glm-4.6
CLAUDE_MODEL=claude-sonnet-4-5-20250929
OPUS_MODEL=claude-opus-4-1-20250805
# Fallback service (only enabled when official keys are missing)
PPINFRA_API_KEY=your-ppinfra-api-keySecurity Note: Recommend chmod 600 ~/.ccm_config to protect your API keys.
CCM now supports managing multiple Claude Pro subscription accounts! Switch between accounts to bypass usage limits without upgrading to Claude Max.
- Bypass Usage Limits: Each Claude Pro account has its own usage limits (5 hours per day, weekly caps)
- Cost-Effective: Multiple Pro accounts are cheaper than one Max account
- Seamless Switching: No need to log out/in - CCM handles authentication automatically
- Secure Storage: Account credentials stored securely in macOS Keychain with local backup
# Save current logged-in account
ccm save-account work # Save as "work"
ccm save-account personal # Save as "personal"
# Switch between accounts
ccm switch-account work # Switch to work account
ccm switch-account personal # Switch to personal account
# View all saved accounts
ccm list-accounts
# Output:
# π Saved Claude Pro accounts:
# - work (Pro, expires: 2025-12-31, β
active)
# - personal (Pro, expires: 2025-12-31)
# Check current account
ccm current-account
# Delete saved account
ccm delete-account old-account# Switch account and select model in one command
ccm opus:work # Switch to work account, use Opus
ccm haiku:personal # Switch to personal account, use Haiku
ccc opus:work # Switch account and launch Claude Code
ccc woohelps # Switch to 'woohelps' account and launch (default model)Step 1: Save your first account
# Login to Claude Code with account 1 in browser
# Launch Claude Code to verify it works
ccm save-account account1Step 2: Save additional accounts
# Quit Claude Code
# Logout from claude.ai in browser
# Login with account 2
# Launch Claude Code again
ccm save-account account2Step 3: Switch between accounts anytime
ccm switch-account account1 # No browser login needed!
# Restart Claude Code for changes to take effectImportant Notes:
- Tokens are refreshed automatically - no re-login needed until they expire
- After switching accounts, restart Claude Code for changes to take effect
- Account credentials are primarily stored in macOS Keychain (most secure)
- Local backup stored in
~/.ccm_accountswith base64 encoding and chmod 600 permissions - Credentials persist across system reboots
- Keychain service name defaults to
Claude Code-credentials. Override viaCCM_KEYCHAIN_SERVICEif your system uses a different name
Security Considerations:
- Always use
chmod 600 ~/.ccm_accountsto protect your local backup - The system relies on macOS Keychain for secure credential storage
- Local backup uses base64 encoding (not encryption) for compatibility
ccm debug-keychain # Inspect current Keychain credentials and match saved accounts
# If it shows no credentials but you are logged in, set service override:
CCM_KEYCHAIN_SERVICE="Claude Code" ccm debug-keychainProblem: "No credentials found in Keychain"
- Solution: Make sure you're logged into Claude Code in your browser or IDE
- Try different keychain service names with
CCM_KEYCHAIN_SERVICEenvironment variable
Problem: "Account switching doesn't work"
- Solution: Restart Claude Code after switching accounts
- Check that the account exists with
ccm list-accounts
Problem: "Permission denied accessing accounts file"
- Solution: Run
chmod 600 ~/.ccm_accountsto fix permissions
Problem: "JSON format error in accounts file"
- Solution: Delete
~/.ccm_accountsand re-save your accounts
Method 1: ccm - Environment Management
ccm deepseek # Switch to DeepSeek
ccm glm # Switch to GLM4.6
ccm pp kimi # Switch to PPINFRA KIMI
claude # Then manually launch Claude CodeMethod 2: ccc - One-Command Launch (Recommended)
ccc deepseek # Switch and launch
ccc pp glm # Switch to PPINFRA and launch
ccc kimi --dangerously-skip-permissions # Pass options to Claude Code# Switch to different models
ccm kimi # Switch to KIMI2
ccm deepseek # Switch to Deepseek
ccm minimax # Switch to MiniMax M2
ccm qwen # Switch to Qwen
ccm kat # Switch to StreamLake (KAT)
ccm glm # Switch to GLM4.6
ccm longcat # Switch to LongCat
ccm claude # Switch to Claude Sonnet 4.5
ccm opus # Switch to Claude Opus 4.1
ccm haiku # Switch to Claude Haiku 4.5
# Switch to PPINFRA service
ccm pp # Interactive PPINFRA model selection
ccm pp deepseek # Direct switch to PPINFRA DeepSeek
ccm pp glm # Direct switch to PPINFRA GLM
ccm pp kimi # Direct switch to PPINFRA KIMI
ccm pp minimax # Direct switch to PPINFRA MiniMax M2
ccm pp qwen # Direct switch to PPINFRA Qwen
# Launch Claude Code
ccc deepseek # Switch to DeepSeek and launch
ccc pp glm # Switch to PPINFRA GLM and launch
ccc opus # Switch to Claude Opus and launch
ccc kat # Switch to StreamLake (KAT) and launch
# Utility commands
ccm status # View current status (masked)
ccm config # Edit configuration
ccm help # Show help
ccc # Show ccc usage help# ccm shortcuts
ccm ds # Short for deepseek
ccm mm # Short for minimax
ccm s # Short for claude sonnet
ccm o # Short for opus
ccm h # Short for haiku
ccm st # Short for status
# ccc shortcuts
ccc ds # Launch with DeepSeek
ccc pp ds # Launch with PPINFRA DeepSeek
ccc kat # Launch with StreamLake (KAT)Example 1: Zero configuration (built-in keys)
ccc deepseek
π Switching to deepseek...
β
Environment configured for: DeepSeek
π Launching Claude Code...
Model: deepseek-chat
Base URL: https://api.ppinfra.com/anthropicExample 2: With your own API keys
export KIMI_API_KEY=your-moonshot-key
ccm kimi
ccm status
π Current model configuration:
BASE_URL: https://api.moonshot.cn/anthropic
AUTH_TOKEN: [Set]
MODEL: kimi-k2-turbo-preview
SMALL_MODEL: kimi-k2-turbo-preview
claude # Launch manuallyExample 3: One-command launch
ccc pp glm --dangerously-skip-permissions
π Switching to PPINFRA glm...
β
Environment configured for: GLM (PPINFRA)
π Launching Claude Code...
Model: zai-org/glm-4.6
Base URL: https://api.ppinfra.com/anthropicCCM implements intelligent fallback:
- Official API Priority: Uses official service if official keys are configured
- Auto Fallback: Automatically switches to PPINFRA backup service when official keys are missing
- Transparent Switching: Seamless to users, commands remain consistent
Alibaba Cloud DashScope (Qwen models):
- Base URL:
https://dashscope.aliyuncs.com/api/v2/apps/claude-code-proxy - Default Models:
qwen3-max(primary),qwen3-next-80b-a3b-instruct(fast) - API Key Format: Standard
sk-prefix from Alibaba Cloud console
PPINFRA Fallback Service:
- Base URL:
https://api.ppinfra.com/anthropic - Supported models:
kimi-k2-turbo-preview(KIMI fallback)deepseek/deepseek-v3.2-exp(Deepseek fallback)MiniMax-M2(MiniMax official)minimax/minimax-m2(MiniMax PPINFRA fallback)qwen3-next-80b-a3b-thinking(Qwen fallback)zai-org/glm-4.6(GLM fallback)
- Status output masks secrets (shows only first/last 4 chars)
- CCM sets only
ANTHROPIC_AUTH_TOKEN(notANTHROPIC_API_KEY) - Configuration file precedence: Environment Variables > ~/.ccm_config
- Recommended file permission:
chmod 600 ~/.ccm_config
# If installed via quick-install.sh or install.sh
./uninstall.sh
# Or manually:
# 1. Remove the ccm/ccc function blocks from ~/.zshrc or ~/.bashrc
# 2. Delete the installation directory
rm -rf ~/.local/share/ccm
rm ~/.ccm_config # optional: remove config fileQ: Getting "XXX_API_KEY not detected" error
A: Check if the API key is correctly configured:
ccm config # Open config file to check
ccm status # View current configurationQ: Claude Code doesn't work after switching
A: Verify environment variables:
ccm status # Check current status
echo $ANTHROPIC_BASE_URL # Check environment variable
env | grep ANTHROPIC # List all ANTHROPIC varsQ: Want to use official service instead of fallback
A: Configure the official API key, CCM will automatically prioritize it:
export DEEPSEEK_API_KEY=sk-your-official-key
ccm deepseekQ: Auth conflict about API_KEY vs AUTH_TOKEN
A: CCM only sets ANTHROPIC_AUTH_TOKEN, unset any conflicting variable:
unset ANTHROPIC_API_KEYIssues and Pull Requests are welcome!
git clone https://github.com/foreveryh/claude-code-switch.git
cd claude-code-switch- Use clear commit messages
- Add appropriate tests
- Update documentation
This project is licensed under the MIT License.
- Claude - AI Assistant
- Deepseek - Efficient reasoning model
- KIMI - Long text processing
- MiniMax - MiniMax M2 model
- Zhipu AI - GLM large model
- Qwen - Alibaba Tongyi Qianwen
β If this project helps you, please give it a Star!
π§ Questions or suggestions? Feel free to submit an Issue