A CLI tool to switch between different AI API providers for Claude Code.
- Switch between Anthropic (default), GLM, MiniMax, and OpenRouter providers
- Auto-launch Claude Code after switching
- Set environment variables easily with one command
- Support for
--no-runflag to set variables without launching
- Clone or download this repository
- Navigate to the repository directory:
cd path/to/ccm - Make the script executable (if needed):
chmod +x cc - Install
fzf(required for OpenRouter's interactive model selection):brew install fzf
Choose one of the following methods:
Option 1 - Add current directory to PATH (temporary, lasts for current session):
export PATH="$(pwd):$PATH"Option 2 - Add specific directory to PATH (permanent):
# For bash
echo 'export PATH="/path/to/ccm:$PATH"' >> ~/.bashrc
# For zsh
echo 'export PATH="/path/to/ccm:$PATH"' >> ~/.zshrc
# Source the file or restart terminal
source ~/.bashrc # or source ~/.zshrc- Copy the sample file:
cp apikeys.json.sample apikeys.json-
Edit
apikeys.jsonand add your actual API keys -
Keep
apikeys.jsonprivate (it's already in.gitignore)
cc dflt # Switch to Anthropic and run claude
cc glm # Switch to GLM and run claude
cc mmx # Switch to MiniMax and run claude
cc optr # Switch to OpenRouter (interactive model selection)
cc optr -m <model> # Switch to OpenRouter with specific model
cc chk # Check current provider statuscc dflt -c # Switch to Anthropic, run with --continue
cc glm -r session-123 # Switch to GLM, resume specific session
cc mmx --continue # Switch to MiniMax, continue conversation# IMPORTANT: When using --no-run or clr, you must SOURCE the script
source cc glm --no-run # Set GLM variables in current shell
source cc clr # Clear variables from current shell
. cc dflt --no-run # Alternative syntax (same as source)After setting variables with source, you can then run claude manually and it will pick up the provider configuration.
| Command | Provider | Base URL |
|---|---|---|
dflt |
Anthropic (default) | https://api.anthropic.com |
glm |
GLM (Z.ai) | https://api.z.ai/api/anthropic |
mmx |
MiniMax | https://api.minimax.io/anthropic |
optr |
OpenRouter | https://openrouter.ai/api |
- Normal commands (
cc dflt,cc glm, etc.) run in a subshell and auto-launchclaudewithin that subshell, so everything works. - Manual mode (
--no-run) and clear command (clr) need to affect your current shell, so you mustsourcethem. - Check command (
chk) only reads variables and works fine either way.
# Use source when you want to set/clear variables but NOT launch claude
source cc glm --no-run # Set vars, then run 'claude' manually
source cc clr # Clear vars from your shell
# No source needed when auto-launching claude
cc glm # This works fine
cc dflt -c # This works fine- When using
cc <provider>without--no-run, the tool will display the switched variables, wait 500ms, clear the screen, and automatically launch Claude Code - When using
source cc <provider> --no-run, variables persist in your current shell for manualclaudeinvocation - The
chkcommand shows which provider is currently active based onANTHROPIC_BASE_URL
- The OpenRouter provider (
optr) requires tool-use compatible models - Model selection is interactive using
fzfwhen available, otherwise falls back to numbered list ANTHROPIC_API_KEYis explicitly set to empty string to prevent 405 authentication errors
MIT License