Published on

Claude-Zhipu Parallel CLI Setup

TL;DR >> This setup allows you to use Claude Code CLI with Zhipu's API (api.z.ai) in parallel with your existing Claude Max / Anthropic CLI installation using a separate command called claude-zhipu. <<

📡 Updated Guide: This article has been updated to reflect the release of GLM-4.7, which introduces interleaved thinking — a new reasoning pattern that interleaves thoughts with actions and responses. See the What’s New in GLM-4.7 section below.


This setup allows you to use Claude Code CLI with Zhipu’s API (api.z.ai) in parallel with your existing Claude Max / Anthropic CLI installation. The new command is called claude-zhipu and it won’t interfere with your normal claude.

Zhipu AI recently launched their GLM-4.7 model with native support for Claude’s API format, making it seamless to use existing Claude tools with their infrastructure.

Zhipu is running 50% off your first GLM Coding Plan purchase this December.

Zhipu AI GLM-4.7 Architecture


# 📦 Installation Steps

1. Prerequisites

  • Node.js v18+ and npm installed:
    node -v && npm -v

If missing, install via nvm or your system package manager.

  • Ensure ~/bin exists and is in your $PATH:

    mkdir -p ~/bin
    echo $PATH | tr ':' '\n' | grep -x "$HOME/bin" || echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc

2. Create a Local Install Folder

mkdir -p ~/claude-zhipu
cd ~/claude-zhipu
npm init -y
npm install @anthropic-ai/claude-code

3. Create a Separate Config Folder

mkdir -p ~/.claude-zhipu

Optional: pre-seed settings.json (not required if using env vars in wrapper):

cat > ~/.claude-zhipu/settings.json <<'JSON'
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_ZHIPU_API_KEY",
    "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
    "API_TIMEOUT_MS": 3000000
  }
}
JSON
chmod 600 ~/.claude-zhipu/settings.json

4. Create a Wrapper Script

cat > ~/bin/claude-zhipu <<'BASH'
#!/usr/bin/env bash
# Wrapper for Claude Code CLI using Zhipu API

CLAUDE_BIN="$HOME/claude-zhipu/node_modules/.bin/claude"

# Inject API credentials
export ANTHROPIC_AUTH_TOKEN="YOUR_ZHIPU_API_KEY"
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_MODEL="GLM-4.7"
export API_TIMEOUT_MS=3000000

# Keep a separate config dir (optional)
export CLAUDE_CONFIG_DIR="$HOME/.claude-zhipu"

exec "$CLAUDE_BIN" "$@"
BASH

chmod +x ~/bin/claude-zhipu

# ▶️ Usage

Run the Zhipu-connected CLI with:

claude-zhipu --version
claude-zhipu chat

Your original Anthropic/Max subscription CLI is still available as:

claude

So you now have two parallel Claude CLIs:

  • claude → uses your existing Anthropic account / subscription
  • claude-zhipu → uses Zhipu API with your custom key

💬 My Experience with the Max Plan

I treated myself to the Max yearly plan for Christmas since they’re running a promo. After 24 hours with three parallel agents running, I’d used about 40% of the 5-hour quota window—plenty for my workflow.

The speed is the real difference: GLM-4.7 does 55+ tokens/second. The Max Plan gets you ~2,400 prompts every 5 hours, or about 3× the Claude Max (20x) allowance.


# 🆕 What’s New in GLM-4.7

GLM-4.7 introduces interleaved thinking — a new reasoning pattern that interleaves thoughts with actions and responses. Instead of generating all thinking at once, the model can now reason iteratively, interacting with tools and refining its approach in real-time.

Interleaved Thinking

The key improvement is the ability to interleave reasoning with tool calls and responses across multiple turns:

Interleaved Thinking Pattern

How it works:

  1. Turn 1 — The model processes your query and generates initial reasoning, then makes a tool call
  2. Tool Result — The tool returns data, which feeds back into the model’s next reasoning step
  3. Step 2+ — Based on tool results, the model refines its reasoning and may make additional tool calls
  4. Answer — After iterative reasoning, the model generates a response

This pattern continues across multiple turns, with each turn building on the full context of previous reasoning, tool calls, and responses.

Why it matters:

  • More accurate results from iterative refinement
  • Better tool use with context-aware decision making
  • Multi-turn conversations maintain full reasoning history
  • Smoother experience with natural back-and-forth

See the official GLM-4.7 announcement for full technical details.


# 🔄 Updating

To update the Zhipu CLI:

cd ~/claude-zhipu
npm update @anthropic-ai/claude-code

# 🗑️ Uninstall

Remove everything with:

rm -rf ~/claude-zhipu
rm -f ~/bin/claude-zhipu
rm -rf ~/.claude-zhipu

# ⚠️ Security

  • Keep your API key secret. The wrapper file contains it in plain text.

  • Restrict permissions if needed:

    chmod 700 ~/bin/claude-zhipu

For better security, consider using pass to store your API key instead of hardcoding it.


# 📚 Additional Resources

Building go-to-market engines for AI-driven products with purpose. Worked with innovative startups like Numarics, Codeanywhere, Daytona, and Steel on growth strategies and market positioning. Faculty at University of Split, researching AI adoption patterns and developer tools.