Interactive provider switcher for Claude Code
Switch between Ollama Cloud, Claude, GLM (z.ai), MiniMax, Xiaomi MiMo, and DeepSeek from one menu.
- Why this exists
- Features
- Supported providers
- Installation
- Usage
- Key storage
- Manage saved keys
- tmux workflow
- Requirements
- Troubleshooting
- License
If you use Claude Code with multiple backends, switching providers manually gets annoying fast.
ai-switch gives you one interactive command that:
- checks dependencies,
- lets you choose a provider,
- lets you choose a model,
- loads the right API settings,
- starts Claude Code with the selected backend.
It is especially useful if you regularly move between:
- free and paid Ollama Cloud models,
- direct Anthropic Claude models,
- GLM via z.ai,
- MiniMax Token Plan,
- Xiaomi MiMo Token Plan,
- DeepSeek API,
- separate
tmuxsessions or multiple projects.
- ā” One command to switch AI backends for Claude Code
- š§ Interactive
fzfmenus - š Built-in Manage saved keys menu
- š¾ Saves provider keys to one persistent config file
- š Auto-checks required tools
- š¦ Auto-installs itself to
/usr/local/bin/ai-switch - š§µ Great fit for
tmuxworkflows - š§© Separate key storage for each provider
Available models include:
minimax-m2.7:cloudminimax-m2.5:cloudglm-4.7:cloudglm-4.6:cloudqwen3.5:cloudqwen3-coder:480b-clouddeepseek-v3.1:671b-clouddeepseek-v3.2:cloudgpt-oss:120b-cloudministral-3:14b-cloudmistral-large-3:675b-cloudnemotron-3-supergemini-3-flash-preview
Uses:
OLLAMA_API_KEY
Available models include:
deepseek-v4-flash:clouddeepseek-v4-pro:cloudkimi-k2.6:cloudglm-5.1:cloudglm-5:cloud
Uses:
OLLAMA_API_KEY
Available models:
claude-opus-4-8claude-sonnet-4-6claude-haiku-4-5-20251001
Uses:
ANTHROPIC_API_KEY
Available models:
glm-5.1glm-5glm-5-turbo
Uses:
ZAI_API_KEY
Available models:
MiniMax-M3MiniMax-M2.7MiniMax-M2.7-highspeed
Uses:
MINIMAX_API_KEY- Sets
ANTHROPIC_BASE_URLtohttps://api.minimax.io/anthropic
Available models:
mimo-v2.5-pro
Uses:
MIMO_API_KEY- Sets
ANTHROPIC_BASE_URLtohttps://api.xiaomimimo.com/anthropic
Available models:
deepseek-v4-prodeepseek-v4-flash
Uses:
DEEPSEEK_API_KEY
curl -fsSL https://raw.githubusercontent.com/noderguru/ai-provider-switch/main/ai-switch -o /tmp/ai-switch && chmod +x /tmp/ai-switch && sudo mv /tmp/ai-switch /usr/local/bin/ai-switchThen run:
ai-switchcurl -fsSL https://raw.githubusercontent.com/noderguru/ai-provider-switch/main/ai-switch -o ai-switch
chmod +x ai-switch
sudo cp ai-switch /usr/local/bin/ai-switch
rm -f ai-switch
hash -rTip
You can also run the script directly once with bash ./ai-switch.
The script is designed to live as a global command at /usr/local/bin/ai-switch.
Start the menu:
ai-switch
Note
If a provider key is already saved, the script reuses it automatically.
If not, it shows the correct link and waits for key input.
All provider keys are stored in one persistent file:
$HOME/.env_ai-provider-switchExample:
OLLAMA_API_KEY="..."
ANTHROPIC_API_KEY="..."
ZAI_API_KEY="..."
MINIMAX_API_KEY="..."
MIMO_API_KEY="..."
DEEPSEEK_API_KEY="..."This means:
- Ollama key does not overwrite DeepSeek key
- Claude key does not overwrite z.ai key
- all providers can coexist in one config file
Important
The script stores keys per provider, not per project directory.
ai-switch includes a built-in key manager.
You can:
- Show saved keys
- Update Ollama key
- Update Claude key
- Update GLM (z.ai) key
- Update MiniMax key
- Update MiMo key
- Update DeepSeek key
- Delete one key
- Delete all keys
- Go back to the main menu
Saved values are shown in masked form for safety.
This tool works very well with tmux.
Example:
# Session 1
tmux new -s frontend
cd ~/frontend-project
ai-switch
# Session 2
tmux new -s backend
cd ~/backend-project
ai-switch
# Session 3
tmux new -s experiments
cd ~/llm-tests
ai-switchThis makes it easy to use different providers for different tasks.
| Tool | Purpose |
|---|---|
| Node.js | Required by Claude Code tooling |
| Ollama | Required for Ollama provider flow |
| Claude Code | Main CLI runner |
| fzf | Interactive menu interface |
The script checks these automatically at startup.
Reinstall the command to /usr/local/bin:
sudo cp ai-switch /usr/local/bin/ai-switch
chmod +x /usr/local/bin/ai-switch
hash -rAdd Claude native path:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcrm -f /usr/local/bin/claude
hash -r
which -a claude
claude doctorCheck whether this file exists:
ls -l $HOME/.env_ai-provider-switchMIT
Built by noderguru