- Expects two config files to exist:
~/.claude/settings.glm.json— your GLM model settings~/.claude/settings.claude.json— your Claude model settings
- Takes one argument: glm or claude (defaults to claude)
- Symlinks
~/.claude/settings.json→ whichever source you picked
- Create the two source config files with whatever settings differ per model:
# Example: copy your current settings as a starting point
cp ~/.claude/settings.json ~/.claude/settings.claude.json
cp ~/.claude/settings.json ~/.claude/settings.glm.json
# Then edit each one for its model~/.claude/settings.glm.json must contains Z.ai required configs, see example below
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "<YOUR Z.AI TOKEN GOES HERE>",
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.1",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "10240"
},
...
}- Save the script somewhere on your $PATH and make it executable:
mkdir -p ~/.local/bin # or wherever you keep personal scripts
# save the script as ~/.local/bin/cc-switch-model
chmod +x ~/.local/bin/cc-switch-model- Make sure
~/.local/binis in your PATH (add to~/.zshrcif not):
export PATH="$HOME/.local/bin:$PATH"Usage
cc-switch-model glm # switch to GLM settings
cc-switch-model claude # switch to Claude settings (default)Note: Claude Code needs to be restarted after switching for the new settings to take effect.