Skip to content

noderguru/ai-provider-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Ā 

History

19 Commits
Ā 
Ā 
Ā 
Ā 
Ā 
Ā 

Repository files navigation

šŸš€ ai-provider-switch

Interactive provider switcher for Claude Code
Switch between Ollama Cloud, Claude, GLM (z.ai), MiniMax, Xiaomi MiMo, and DeepSeek from one menu.

Bash Claude Code fzf MIT


Table of contents


Why this exists

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 tmux sessions or multiple projects.

Features

  • ⚔ One command to switch AI backends for Claude Code
  • 🧭 Interactive fzf menus
  • šŸ” 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 tmux workflows
  • 🧩 Separate key storage for each provider

Supported providers

Ollama Cloud (Free)

Available models include:

  • minimax-m2.7:cloud
  • minimax-m2.5:cloud
  • glm-4.7:cloud
  • glm-4.6:cloud
  • qwen3.5:cloud
  • qwen3-coder:480b-cloud
  • deepseek-v3.1:671b-cloud
  • deepseek-v3.2:cloud
  • gpt-oss:120b-cloud
  • ministral-3:14b-cloud
  • mistral-large-3:675b-cloud
  • nemotron-3-super
  • gemini-3-flash-preview

Uses:

  • OLLAMA_API_KEY

Ollama Cloud (Paid Pro/Max)

Available models include:

  • deepseek-v4-flash:cloud
  • deepseek-v4-pro:cloud
  • kimi-k2.6:cloud
  • glm-5.1:cloud
  • glm-5:cloud

Uses:

  • OLLAMA_API_KEY

Claude

Available models:

  • claude-opus-4-8
  • claude-sonnet-4-6
  • claude-haiku-4-5-20251001

Uses:

  • ANTHROPIC_API_KEY

GLM (z.ai)

Available models:

  • glm-5.1
  • glm-5
  • glm-5-turbo

Uses:

  • ZAI_API_KEY

MiniMax Token Plan

Available models:

  • MiniMax-M3
  • MiniMax-M2.7
  • MiniMax-M2.7-highspeed

Uses:

  • MINIMAX_API_KEY
  • Sets ANTHROPIC_BASE_URL to https://api.minimax.io/anthropic

Xiaomi MiMo Token Plan

Available models:

  • mimo-v2.5-pro

Uses:

  • MIMO_API_KEY
  • Sets ANTHROPIC_BASE_URL to https://api.xiaomimimo.com/anthropic

DeepSeek API (Pay-per-token)

Available models:

  • deepseek-v4-pro
  • deepseek-v4-flash

Uses:

  • DEEPSEEK_API_KEY

Installation

Quick install

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-switch

Then run:

ai-switch

Manual install

curl -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 -r

Tip

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.


Usage

Start the menu:

ai-switch
image image

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.


Key storage

All provider keys are stored in one persistent file:

$HOME/.env_ai-provider-switch

Example:

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.


Manage saved keys

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.


tmux workflow

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-switch

This makes it easy to use different providers for different tasks.


Requirements

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.


Troubleshooting

ai-switch: command not found

Reinstall the command to /usr/local/bin:

sudo cp ai-switch /usr/local/bin/ai-switch
chmod +x /usr/local/bin/ai-switch
hash -r

Claude native install is not found

Add Claude native path:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Claude warns about multiple installations

rm -f /usr/local/bin/claude
hash -r
which -a claude
claude doctor

Saved keys seem missing

Check whether this file exists:

ls -l $HOME/.env_ai-provider-switch

License

MIT

Built by noderguru

About

One-command interactive switcher for Claude Code between Ollama Cloud (MiniMax, Qwen, GLM, GPT-OSS) and DeepSeek API (V4 Pro / Flash). Auto-detects missing dependencies, prompts for API keys, and launches Claude Code with the selected provider.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors