A wrapper for Claude Code that uses z.ai API servers without polluting your global Claude Code settings.
⚡ Quick Install:
curl -fsSL https://raw.githubusercontent.com/karolswdev/zlaude/main/install.sh | bash
When you want to use Claude Code with both the official Anthropic API and z.ai's API, you face a dilemma: the configuration is global in ~/.claude/settings.json. Switching between providers means constantly editing this file, which is tedious and error-prone.
zlaude is a simple wrapper script that:
- ✅ Sets z.ai-specific environment variables before launching Claude Code
- ✅ Keeps your global Claude Code settings untouched
- ✅ Allows you to use
claudefor Anthropic andzlaudefor z.ai simultaneously - ✅ Works on Mac and Linux (Windows users... sorry!)
- ✅ Zero dependencies beyond bash and Node.js
- ✅ Interactive installer handles everything
- 🔄 Parallel Usage: Run both Anthropic and z.ai Claude instances without conflicts
- 🔐 Secure Config: API keys stored in
~/.zlaude/config(not in global settings) - ⚙️ Flexible: Override API keys via CLI args or environment variables
- 📦 Simple: Just a bash script - no Docker, no complex setup
- 🚀 Fast: Instant startup, zero overhead
- 🔧 Interactive Setup:
zlaude --configurewalks you through configuration
Instead of modifying ~/.claude/settings.json, zlaude sets environment variables that Claude Code reads:
ANTHROPIC_AUTH_TOKEN- Your z.ai API keyANTHROPIC_BASE_URL- Points tohttps://api.z.ai/api/anthropicAPI_TIMEOUT_MS- Extended timeout for z.ai- Model mappings for GLM models
These environment variables are process-specific, so they only affect the Claude Code instance launched by zlaude.
One-liner install from GitHub:
curl -fsSL https://raw.githubusercontent.com/karolswdev/zlaude/main/install.sh | bashOr clone and install:
git clone https://github.com/karolswdev/zlaude.git
cd zlaude
./install.shThe installer will:
- ✓ Check for prerequisites (Node.js and Claude Code)
- ✓ Offer to install Claude Code if not present
- ✓ Install the
zlaudecommand to your system - ✓ Optionally configure your z.ai API key
# Make the script executable
chmod +x zlaude
# Copy to a directory in your PATH
sudo cp zlaude /usr/local/bin/
# OR for user-only install:
cp zlaude ~/.local/bin/zlaude --configureThis will prompt you for your z.ai API key and save it to ~/.zlaude/config.
Create ~/.zlaude/config with:
ZLAUDE_API_KEY=your_api_key_here- Visit z.ai Open Platform
- Register or login
- Go to API Keys
- Create and copy your API key
# Launch Claude Code with z.ai
zlaude
# Use in any directory
cd ~/my-project
zlaude# Configure or update API key
zlaude --configure
# Use a specific API key (overrides config)
zlaude --api-key YOUR_API_KEY
# Show help
zlaude --helpAll arguments after zlaude options are passed directly to Claude Code:
# These work just like with 'claude'
zlaude --help # zlaude's help
zlaude -- --help # Claude Code's help
zlaude /status # Check status in Claude CodeYou can customize zlaude's behavior with environment variables:
ZLAUDE_API_KEY- Override the API key from config fileZLAUDE_CONFIG_DIR- Config directory (default:~/.zlaude)ZLAUDE_CONFIG_FILE- Config file path (default:~/.zlaude/config)
Example:
# Use a different API key for one session
ZLAUDE_API_KEY=other_key zlaude
# Use a different config directory
ZLAUDE_CONFIG_DIR=~/my-configs zlaudezlaude automatically maps Claude models to z.ai's GLM models:
claude-opus-*→GLM-4.6claude-sonnet-*→GLM-4.6claude-haiku-*→glm-4.5-air
You can check the current model configuration in Claude Code with:
zlaude
> /statusWe considered using Docker to isolate the configuration, but opted for the simpler environment variable approach because:
- Simplicity - No Docker daemon required, works everywhere
- Performance - No container overhead, instant startup
- Integration - Seamless access to your filesystem and tools
- Portability - Just a shell script, easy to understand and modify
The environment variable approach gives us clean isolation without the complexity of containerization.
# Morning: Work with Anthropic's Claude
claude
> help me refactor this code...
# Afternoon: Switch to z.ai for cost savings
zlaude
> continue the refactoring...
# Both work simultaneously, no conflicts!# Use your personal key
zlaude
> ...
# Use your work key
zlaude --api-key work_api_key
> ...
# Use a project-specific key
ZLAUDE_API_KEY=project_key zlaude
> ...Claude Code is not installed. Install it with:
npm install -g @anthropic-ai/claude-codeThe installation directory is not in your PATH. Either:
-
Add it to PATH in
~/.bashrcor~/.zshrc:export PATH="/usr/local/bin:$PATH"
-
Or use the full path:
/usr/local/bin/zlaude
Run zlaude --configure to set up your API key.
If you're having trouble connecting to z.ai:
- Verify your API key is correct
- Check your internet connection
- Try increasing the timeout (zlaude already sets it to 3000000ms)
zlaude/
├── zlaude # Main wrapper script (sets env vars, launches claude)
├── install.sh # Interactive installer for Mac/Linux
├── uninstall.sh # Interactive uninstaller
├── verify.sh # Installation verification script
├── config.example # Example configuration file
├── .gitignore # Prevents committing sensitive data
├── LICENSE # MIT License
├── README.md # This file
└── CONTRIBUTING.md # Contribution guidelines
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Ideas for contributors:
- Add support for additional z.ai configuration options
- Create an uninstaller script ✓
- Add shell completion (bash/zsh)
- Support for multiple provider profiles (not just z.ai)
- Auto-update mechanism
- Homebrew formula for easier installation
MIT License - See LICENSE file for details.
- Claude Code by Anthropic
- z.ai API by BigModel/GLM team
- Created by @karolswdev as a practical solution to a real problem
If you find this tool useful:
- ⭐ Star this repository
- 🐛 Report issues on GitHub Issues
- 💡 Suggest features or improvements
- 🤝 Contribute via pull requests
No, zlaude is specifically for z.ai. For Anthropic's API, use the regular claude command.
Yes! That's the whole point. Use claude for Anthropic and zlaude for z.ai without any conflicts.
No, zlaude doesn't modify any global settings. Your ~/.claude/settings.json remains untouched.
The creator explicitly stated "No one cares about Windows" in the requirements. But if you do care, you could port this to a PowerShell script or use WSL.
No, the environment variable approach is simpler and works perfectly. Docker would add unnecessary complexity.
Easy way (recommended):
./uninstall.shManual removal:
# Remove the command
sudo rm /usr/local/bin/zlaude
# OR for user install:
rm ~/.local/bin/zlaude
# Optionally remove config
rm -rf ~/.zlaudeHappy coding with z.ai! 🚀