This tutorial is fully based on a Reddit post for broader reach. All proper credit goes to ThreeKiloZero.
Reddit post:
https://www.reddit.com/r/ClaudeCode/comments/1p27ly4/how_to_set_up_claude_code_with_multiple_ai_models/
Author:
https://www.reddit.com/user/ThreeKiloZero/
This guide provides a simplified approach to configuring your terminal using Bash, allowing you to easily switch between different AI models when using Claude Code.
The setup is also highly adaptable for .zshrc and other shells, requiring only minor syntax adjustments for environment variables and functions.
What this does
Instead of being limited to a single AI model, you will be able to run
commands such as:
-
claude- Uses the default Claude AI -
claudekimi- Uses Kimi for coding -
claudeglm- Uses Z.AI GLM models -
claudem25- Uses MiniMax M2.5 -
claude m25orclaude kimi- Alternative way to switch models
Before you start
You will need:
- Claude Code installed on your computer (CLI version)
- API keys for the AI services you want to use
- Bash configured
Step 1: Installing Claude Code
If you do not have Claude Code installed yet, run:
curl -fsSL https://claude.ai/install.sh | bash
Step 2: Get your API keys
Create accounts on the AI services you want to use and obtain your API
keys:
- Kimi for Coding: Get your key from the Kimi developer portal
- Z.AI (GLM models): Get your key from Z.AI
- MiniMax: Get your key from MiniMax
Store these keys in a safe place.
Step 3: Configure your API keys
Open your Bash configuration file:
nano ~/.bashrc
Add the following lines, replacing them with your real API keys:
# API keys for different AI services
export KIMI_API_KEY="your-kimi-api-key"
export ZAI_API_KEY="your-zai-api-key"
export MINIMAX_API_KEY="your-minimax-api-key"
Step 4: Add model configurations
Run which claude to get directory of claude
Add these functions to your ~/.bashrc and change directory of claude:
Kimi for Coding
claudekimi() {
if [ -z "$KIMI_API_KEY" ]; then
echo "Error: KIMI_API_KEY is not set. Add it to ~/.bashrc"
return 1
fi
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="https://api.kimi.com/coding/"
export ANTHROPIC_AUTH_TOKEN="$KIMI_API_KEY"
export ANTHROPIC_MODEL="kimi-for-coding"
export ANTHROPIC_SMALL_FAST_MODEL="kimi-for-coding"
# Claude directory
/home/{yourusername}/.local/bin/claude "$@"
}
Z.AI GLM models
claudeglm() {
if [ -z "$ZAI_API_KEY" ]; then
echo "Error: ZAI_API_KEY is not set. Add it to ~/.bashrc"
return 1
fi
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="$ZAI_API_KEY"
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-4.6"
export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-4.6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-4.5-air"
# Claude directory
/home/{yourusername}/.local/bin/claude "$@"
}
MiniMax M2.5
claudem25() {
if [ -z "$MINIMAX_API_KEY" ]; then
echo "Error: MINIMAX_API_KEY is not set. Add it to ~/.bashrc"
return 1
fi
unset ANTHROPIC_API_KEY
export ANTHROPIC_BASE_URL="https://api.minimax.io/anthropic"
export ANTHROPIC_AUTH_TOKEN="$MINIMAX_API_KEY"
export API_TIMEOUT_MS="3000000"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
export ANTHROPIC_MODEL="MiniMax-M2.5"
export ANTHROPIC_SMALL_FAST_MODEL="MiniMax-M2.5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="MiniMax-M2.5"
export ANTHROPIC_DEFAULT_OPUS_MODEL="MiniMax-M2.5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="MiniMax-M2.5"
# Claude directory
/home/{yourusername}/.local/bin/claude "$@"
}
Dispatcher function (optional)
claude() {
first_arg="$1"
case "$first_arg" in
m25|M25)
shift
claudem25 "$@"
;;
kimi|K2)
shift
claudekimi "$@"
;;
glm|GLM)
shift
claudeglm "$@"
;;
*)
/home/{yourusername}/.local/bin/claude "$@"
;;
esac
}
Step 5: Reload configuration
source ~/.bashrc
Step 6: Test
# Kimi
$ claudekimi
$ claude kimi
# MiniMax
$ claudem25
$ claude m25
# GLM
$ claudeglm
$ claude glm
If everything is configured correctly, Claude Code will start using the
selected AI model.
Troubleshooting
Command not found
- Reload config
- Verify function definitions
API key not defined
- Check variables
- Reload config
Connection error
- Validate API key
- Check internet connection
- Confirm endpoint URL
How it works
Each function:
- Checks API key
- Configures connection
- Runs Claude Code
The dispatcher function selects the correct configuration automatically.
Adding more AI models
- Add API key
- Create function
- Set base URL
- Set auth token
- Configure models
- Add to dispatcher
Done! You now have a flexible setup to switch between AI models with
simple commands.
RELATED NOTES
How to configure Claude CLI ACP for other compatible models, such as MiniMax M2.5
https://dev.to/hallancosta/how-to-configure-claude-cli-acp-for-other-compatible-models-such-as-minimax-m25-3j4n
How to configure ACP agents in Zed
https://dev.to/hallancosta/how-to-configure-acp-agents-in-zed-521e
Top comments (0)