GLM CLI
A command-line interface for launching Claude Code with GLM (ChatGLM) settings via BigModel API, using temporary session-based configuration.
Features
- 🚀 Session-Based Launch: Launch Claude with GLM settings temporarily (no persistent config changes)
- 🎯 Model Selection: Choose different GLM models at launch time (glm-5, glm-4.7, glm-4.6, glm-4.5, glm-4.5-air, etc.)
- 🔀 Flag Passthrough: Pass any claude CLI flags directly through glm (e.g.,
--allowedTools, --verbose)
- ⚡ YOLO Mode: Skip permission prompts with
--yolo flag for faster workflows
- 📦 Auto-Install: Install Claude Code with built-in npm dependency checking
- 🔄 Auto-Update: Check for and install updates with interactive update command
- ⚙️ Token Management: Securely manage your authentication token
Installation
Quick Install (Recommended)
Automatic Installer:
curl -fsSL https://raw.githubusercontent.com/xqsit94/glm/main/install.sh | bash
Alternative - Manual Quick Install:
# Create user bin directory and download GLM CLI
mkdir -p ~/.local/bin
curl -L -o ~/.local/bin/glm "https://github.com/xqsit94/glm/releases/download/v1.2.0/glm-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/amd64/')"
chmod +x ~/.local/bin/glm
# Add to PATH (one-time setup)
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Both methods will:
- Detect your operating system and architecture
- Download the latest binary release
- Install to your user directory
- Set up PATH for easy access
Manual Installation
Option 1: Download Pre-built Binary
- Go to the releases page
- Download the binary for your platform:
- macOS Intel:
glm-darwin-amd64
- macOS Apple Silicon:
glm-darwin-arm64
- Linux x64:
glm-linux-amd64
- Linux ARM64:
glm-linux-arm64
- Make it executable and move to PATH:
chmod +x glm-*
sudo mv glm-* /usr/local/bin/glm
Option 2: Build from Source
Prerequisites:
- Go 1.24 or later
- Your GLM API token
git clone https://github.com/xqsit94/glm.git
cd glm
go mod tidy
go build -o glm
sudo mv glm /usr/local/bin/
Authentication Setup
The GLM CLI supports multiple ways to provide your Anthropic API token:
Option 1: Interactive Setup (Recommended)
On first run, the CLI will automatically prompt you to set up your token:
glm # Will prompt for token if not found
Option 2: Manual Token Setup
glm token set # Enter your token securely
Option 3: Environment Variable
export ANTHROPIC_AUTH_TOKEN="your_token_here"
glm
Token Priority Order:
- Environment variable
ANTHROPIC_AUTH_TOKEN
- Config file
~/.glm/config.json
- Interactive prompt
Usage
Launch Claude with GLM (Primary Usage)
Launch Claude with the default model (glm-5):
glm
Launch Claude with a specific model:
glm --model glm-4.5-air
glm -m glm-4.5-air
Launch Claude in YOLO mode (skip permission prompts):
glm --yolo
glm --yolo --model glm-4.5-air
Pass additional flags directly to claude:
glm --allowedTools "Bash,Read,Write"
glm --verbose
glm --yolo --allowedTools "Bash,Read"
How it works:
- Sets temporary environment variables for the Claude session
- No persistent changes to Claude's configuration files
- Settings only apply to the launched Claude session
- To use Claude without GLM, just run
claude directly
Install Claude Code
Install Claude Code via npm (with automatic Node.js detection):
glm install claude
Manage Authentication Token
Set your API token:
glm token set
View current token (masked):
glm token show
Clear stored token:
glm token clear
Update GLM
Check for updates:
glm update --check
Update to latest version:
glm update
Update without confirmation:
glm update --force
Help
Get help for any command:
glm --help
glm install --help
glm token --help
glm update --help
Commands Reference
| Command |
Description |
Example |
glm |
Launch Claude with GLM (temporary config) |
glm --model glm-5 |
glm --yolo |
Launch with permission prompts skipped |
glm --yolo |
glm --<flag> |
Pass any flag through to claude |
glm --allowedTools "Bash" |
glm install claude |
Install Claude Code |
glm install claude |
glm token set |
Set authentication token |
glm token set |
glm token show |
Show current token (masked) |
glm token show |
glm token clear |
Clear stored token |
glm token clear |
glm update |
Update GLM to latest version |
glm update |
glm update --check |
Check for updates only |
glm update --check |
Deprecated Commands
These commands still work but are deprecated. Use glm with --model flag instead:
| Command |
Status |
Replacement |
glm enable |
⚠️ Deprecated |
Use glm instead |
glm disable |
⚠️ Deprecated |
Run claude directly |
glm set |
❌ Removed |
Use glm --model X |
Available Models
glm-5 (default)
glm-4.7
glm-4.6
glm-4.5
glm-4.5-air
- Any other GLM model supported by BigModel API
Configuration Files
The CLI manages the following files:
~/.glm/config.json - Your authentication token and preferences
Note: GLM no longer modifies ~/.claude/settings.json. All configuration is passed via temporary environment variables.
How It Works
-
Launch (glm): Launches Claude Code with temporary environment variables:
ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
ANTHROPIC_AUTH_TOKEN=<your_token>
ANTHROPIC_MODEL=<selected_model>
-
Session-Based: Settings only exist for the launched Claude session. No persistent file modifications.
-
Token Storage: Your authentication token is securely stored in ~/.glm/config.json for convenience.
-
Install: Checks for npm and installs Claude Code globally.
-
Update: Downloads and replaces the GLM binary with the latest version from GitHub.
Example Workflow
# Install GLM CLI
curl -fsSL https://raw.githubusercontent.com/xqsit94/glm/main/install.sh | bash
# First time setup
glm install claude # Install Claude Code
glm token set # Enter your token securely
# Launch Claude with GLM (default model: glm-5)
glm
# Launch with specific model
glm --model glm-4.5-air
# Launch in YOLO mode (skip permission prompts)
glm --yolo
# Pass additional flags to claude
glm --allowedTools "Bash,Read,Write"
# Use Claude without GLM
claude
# Check for updates
glm update --check
# Update to latest version
glm update
Troubleshooting
Installation Issues
curl not found
If you get a "curl not found" error:
- macOS: Install Xcode Command Line Tools:
xcode-select --install
- Linux: Install curl:
sudo apt install curl (Ubuntu/Debian) or sudo yum install curl (CentOS/RHEL)
Permission denied during installation
If the installer fails with permission errors:
# Download and run manually with explicit sudo
curl -fsSL https://raw.githubusercontent.com/xqsit94/glm/main/install.sh -o install.sh
chmod +x install.sh
sudo ./install.sh
If no binary is available for your platform:
- Check the releases page for available binaries
- Build from source using the manual installation instructions
Runtime Issues
npm not found
If you get an npm error when running glm install claude:
- Install Node.js from https://nodejs.org/
- Restart your terminal
- Run
glm install claude again
Authentication token not found
Set up your token using any of these methods:
glm token set (recommended)
- Set environment variable:
export ANTHROPIC_AUTH_TOKEN="your_token"
Claude still using default settings
The session-based configuration means:
- Settings only apply to Claude sessions launched via
glm
- If you run
claude directly, it uses default settings
- This is intentional - use
glm to launch with GLM settings
Command not found after installation
If glm command is not found after installation:
- Check if
/usr/local/bin or ~/.local/bin is in your PATH: echo $PATH
- Add to PATH if missing (add to
.bashrc, .zshrc, etc.):
export PATH="$HOME/.local/bin:$PATH"
- Restart your terminal or run:
source ~/.bashrc (or .zshrc)
Update fails with permission error
If glm update fails with permission denied:
sudo glm update
Migration from Previous Versions
If you're upgrading from version 1.0.x:
⚠️ IMPORTANT: Remove Old Configuration File
You MUST remove the old persistent configuration file to avoid conflicts:
rm -f ~/.claude/settings.json
Why this is required:
- Version 1.0.x created a persistent
~/.claude/settings.json file that made Claude always use GLM settings
- This conflicts with v1.1.0's session-based approach
- Without removing this file: Running
claude directly will still use GLM settings (not the default)
- After removing this file:
glm → Uses GLM settings (temporary, session-based)
claude → Uses default Claude settings (no GLM)
Other Changes:
- Deprecated commands:
glm enable and glm disable still work but show deprecation warnings
- Removed command:
glm set has been removed - use glm --model X instead
- New usage: Just run
glm to launch Claude with GLM, or glm --model X to specify a model
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and feature requests, please create an issue in the repository.