Last active
January 21, 2026 22:24
-
-
Save emaballarin/33079c5a31726c2a2347e09f3a46d1f1 to your computer and use it in GitHub Desktop.
Adapt Claude Code to work on-demand with Z.ai GML 4.7, MiniMax M2.1, and Ollama-provided models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env fish | |
| function ccglm --description "Claude Code with GLM 4.7 (Z.AI)" | |
| if test -f ~/.secrets/zai.fish | |
| source ~/.secrets/zai.fish | |
| else | |
| echo "Error: ~/.secrets/zai.fish not found" >&2 | |
| echo "Create it with: set -gx Z_AI_API_KEY 'your-key'" >&2 | |
| return 1 | |
| end | |
| if not set -q Z_AI_API_KEY; or test -z "$Z_AI_API_KEY" | |
| echo "Error: Z_AI_API_KEY not set in ~/.secrets/zai.fish" >&2 | |
| return 1 | |
| end | |
| set -lx ANTHROPIC_BASE_URL "https://api.z.ai/api/anthropic" | |
| set -lx ANTHROPIC_AUTH_TOKEN "$Z_AI_API_KEY" | |
| set -lx ANTHROPIC_DEFAULT_HAIKU_MODEL "glm-4.5-air" | |
| set -lx ANTHROPIC_DEFAULT_SONNET_MODEL "glm-4.7" | |
| set -lx ANTHROPIC_DEFAULT_OPUS_MODEL "glm-4.7" | |
| set -lx API_TIMEOUT_MS "3000000" | |
| set -lx CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 1 | |
| set -e ANTHROPIC_API_KEY 2>/dev/null | |
| claude $argv | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env fish | |
| function ccmmx --description "Claude Code with MiniMax-M2.1" | |
| if test -f ~/.secrets/minimax.fish | |
| source ~/.secrets/minimax.fish | |
| else | |
| echo "Error: ~/.secrets/minimax.fish not found" >&2 | |
| echo "Create it with: set -gx MINIMAX_API_KEY 'your-key'" >&2 | |
| return 1 | |
| end | |
| if not set -q MINIMAX_API_KEY; or test -z "$MINIMAX_API_KEY" | |
| echo "Error: MINIMAX_API_KEY not set in ~/.secrets/minimax.fish" >&2 | |
| return 1 | |
| end | |
| set -lx ANTHROPIC_BASE_URL "https://api.minimax.io/anthropic" | |
| set -lx ANTHROPIC_AUTH_TOKEN "$MINIMAX_API_KEY" | |
| set -lx ANTHROPIC_MODEL "MiniMax-M2.1" | |
| set -lx ANTHROPIC_SMALL_FAST_MODEL "MiniMax-M2.1" | |
| set -lx ANTHROPIC_DEFAULT_HAIKU_MODEL "MiniMax-M2.1" | |
| set -lx ANTHROPIC_DEFAULT_SONNET_MODEL "MiniMax-M2.1" | |
| set -lx ANTHROPIC_DEFAULT_OPUS_MODEL "MiniMax-M2.1" | |
| set -lx API_TIMEOUT_MS "3000000" | |
| set -lx CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 1 | |
| set -e ANTHROPIC_API_KEY 2>/dev/null | |
| claude $argv | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ccollama.fish - Launch Claude Code with Ollama models (local or cloud) | |
| # Place in: ~/.config/fish/functions/ccollama.fish | |
| function ccollama --description "Claude Code with Ollama (local/cloud)" | |
| # Load Ollama config from secrets file (optional, for API key and default model) | |
| if test -f ~/.secrets/ollama.fish | |
| source ~/.secrets/ollama.fish | |
| end | |
| # Set Ollama environment (local to this command) | |
| set -lx ANTHROPIC_BASE_URL "http://localhost:11434" | |
| set -lx ANTHROPIC_AUTH_TOKEN "ollama" # Required but ignored for local models | |
| set -lx API_TIMEOUT_MS "3000000" | |
| set -lx CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 1 | |
| # Use custom API key if set (for cloud or future use) | |
| if set -q OLLAMA_API_KEY; and test -n "$OLLAMA_API_KEY" | |
| set -lx ANTHROPIC_AUTH_TOKEN "$OLLAMA_API_KEY" | |
| end | |
| # Ensure Anthropic API key doesn't interfere | |
| set -e ANTHROPIC_API_KEY 2>/dev/null | |
| # Check if --model is already in arguments | |
| set -l has_model 0 | |
| for arg in $argv | |
| if string match -q -- "--model" $arg; or string match -q -- "-m" $arg | |
| set has_model 1 | |
| break | |
| end | |
| # Also check for --model=value format | |
| if string match -q -- "--model=*" $arg | |
| set has_model 1 | |
| break | |
| end | |
| end | |
| # If no --model specified and default is set, inject it | |
| if test $has_model -eq 0; and set -q CCOLLAMA_DEFAULT_MODEL; and test -n "$CCOLLAMA_DEFAULT_MODEL" | |
| ~/.local/bin/claude --model "$CCOLLAMA_DEFAULT_MODEL" $argv | |
| else if test $has_model -eq 0 | |
| echo "Note: No model specified. Use --model <name> or set CCOLLAMA_DEFAULT_MODEL" >&2 | |
| echo "Recommended: gpt-oss:20b, qwen3-coder (local) | glm-4.7:cloud, minimax-m2.1:cloud (cloud)" >&2 | |
| ~/.local/bin/claude $argv | |
| else | |
| ~/.local/bin/claude $argv | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment