Use GLM-5 (Alibaba Cloud Coding Plan or Z.AI) with Rune Plugin
This guide helps you configure GLM-5 from Chinese providers to work with the Rune plugin.
Why consider this option?
- 💰 Budget-friendly — If you can't afford expensive models like Claude Max ($200/month), this offers a cost-effective alternative starting at $10/month
- 🧪 Test Agent Teams — Great for testing Rune's agent teams features at lower cost (Claude Pro $20/month is not enough for heavy agent usage)
⚠️ Trade-offs — Consider potential security and data collection implications when using models from Chinese providers. Use for non-sensitive projects.
Disclaimer: This is NOT an official endorsement. Evaluate your own security requirements before use.
Uses claude-code-router to route Claude Code requests through Alibaba's GLM-5.
- Node.js 18+ installed
- Claude Code CLI installed (
npm install -g @anthropic-ai/claude-code) - Active Alibaba Cloud Coding Plan subscription
-
Choose a subscription tier:
Plan Price Quotas Lite $10/month 1,200 req/5hrs, 9,000/week, 18,000/month Pro $50/month 6,000 req/5hrs, 45,000/week, 90,000/month -
Available Models:
Model Notes glm-5Recommended for coding - Stable speed, good reasoning glm-4.7Alternative GLM version qwen3.5-plusGeneral purpose qwen3-maxPro plan only, advanced tasks qwen3-coder-plusCode optimization kimi-k2.5Long context MiniMax-M2.5Alternative model -
Complete subscription and obtain your Coding Plan API Key (starts with
sk-sp-)
Tip: A simple task consumes ~5-10 invocations, complex tasks can use 10-30+ invocations. Recommended: Use
glm-5for coding — stable speed and solid reasoning.
npm install -g @musistudio/claude-code-routerCreate or edit ~/.claude-code-router/config.json:
{
"LOG": true,
"LOG_LEVEL": "debug",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": "600000",
"Providers": [
{
"name": "Alibaba Cloud",
"api_base_url": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1/messages",
"api_key": "${ALIBABA_CODING_PLAN_API_KEY}",
"models": ["glm-5"],
"transformer": {
"use": ["Anthropic"],
"glm-5": {
"use": ["Anthropic"]
}
}
}
],
"Router": {
"default": "Alibaba Cloud,glm-5",
"background": "Alibaba Cloud,glm-5",
"think": "Alibaba Cloud,glm-5",
"longContext": "Alibaba Cloud,glm-5",
"longContextThreshold": 60000
}
}Note: Use
coding-intl.dashscope.aliyuncs.com(international endpoint) and the/apps/anthropic/v1/messagespath for Anthropic-compatible API.
Add your API key to your shell profile (~/.zshrc or ~/.bashrc):
export ALIBABA_CODING_PLAN_API_KEY="sk-sp-your-api-key-here"Reload your shell:
source ~/.zshrc # or ~/.bashrcStart the router in daemon mode:
ccr start --daemonTip: If
ccr start --daemonfails, use this alias as an alternative:# Add to ~/.zshrc or ~/.bashrc alias ccrd='ccr start --daemon &' # Then run ccrd
Or start Claude Code directly with the router:
ccr codeOther useful commands:
ccr model # Interactive model selector
ccr ui # Web-based configuration interface
ccr preset # Manage configuration presets
ccr activate # Output environment variables for shell
ccr restart # Restart after config changes
ccr stop # Stop the daemon
ccr status # Check router status# Server logs
~/.claude-code-router/logs/ccr-*.log
# Application logs
~/.claude-code-router/claude-code-router.logOnce configured, all Rune commands will automatically route through GLM-5:
# Example Rune commands
/rune:appraise # Code review
/rune:devise # Planning
/rune:strive # Implementation
/rune:audit # Full codebase auditExample: /rune:audit running with 14 teammates on GLM-5:
- Personal use only - Coding Plan subscriptions are for individual use
- No automated scripts - Use only in interactive coding tools (Claude Code, OpenClaw)
- Use correct endpoint - Always use
coding.dashscope.aliyuncs.com, NOT the general Model Studio endpoint - Non-refundable - Subscriptions cannot be refunded
| Issue | Solution |
|---|---|
ccr: command not found |
Ensure npm global bin is in PATH: npm config get prefix |
401 Unauthorized |
Verify API key starts with sk-sp- and is correctly set |
Model not found |
Check model name matches: glm-5 (lowercase) |
| Connection timeout | Check network/proxy settings, verify api_base_url |
Why Z.AI over Alibaba? Simpler setup (no router needed), direct Anthropic-compatible API, less prone to getting stuck during execution.
- Visit Z.AI GLM Coding Plan
- Subscribe (plans from $10/month)
- Get your API key from z.ai/manage-apikey/apikey-list
Edit ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_MODEL": "GLM-4.7",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "GLM-4.7",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "GLM-4.7",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "GLM-4.5-Air",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": 1
}
}No router setup needed. Just run:
claude| Model | Best For |
|---|---|
GLM-4.7 |
Recommended — Default for Opus/Sonnet tasks |
GLM-5 |
Latest model — Good for coding |
GLM-4.5-Air |
Fast, lightweight — Default for Haiku tasks |
GLM-4.6V |
Vision tasks |
# macOS/Linux
curl -O "https://cdn.bigmodel.cn/install/claude_code_zai_env.sh" && bash ./claude_code_zai_env.sh
# Or use the helper
npx @z_ai/codinghelper| Issue | Solution |
|---|---|
| Config not taking effect | Close all Claude Code windows and reopen |
| JSON errors | Validate with online JSON validator |
| Version issues | Run claude update to upgrade |
Current limitation: Agent teams (teammates) in Claude Code do not work well with direct custom model configuration. Even when ANTHROPIC_MODEL is set, teammates may still call Claude Opus or Sonnet instead of your custom model.
Recommended solution: Use claude-code-router (Option A) for agent teams support. The router intercepts all API calls, ensuring teammates use your configured model.
| Setup Method | Agent Teams Support | Notes |
|---|---|---|
| Direct env config (Z.AI) | Teammates may ignore custom model | |
| claude-code-router (Alibaba) | ✅ Works | Router enforces model for all calls |
This is a known limitation that will likely be improved in future Claude Code updates.
Hướng dẫn này giúp bạn cấu hình GLM-5 từ Alibaba Cloud Coding Plan để sử dụng với Rune plugin thông qua claude-code-router.
Tại sao nên cân nhắc phương án này?
- 💰 Tiết kiệm chi phí — Nếu bạn không đủ tiền mua các model đắt tiền như Claude Max ($200/tháng), đây là giải pháp thay thế với giá từ $10/tháng
- 🧪 Test Agent Teams — Phù hợp để test tính năng agent teams của Rune với chi phí thấp hơn (Claude Pro $20/tháng không đủ cho việc dùng agent nhiều)
⚠️ Đánh đổi — Cân nhắc các vấn đề tiềm ẩn về bảo mật và thu thập dữ liệu khi dùng model từ nhà cung cấp Trung Quốc. Nên dùng cho các dự án không nhạy cảm.
Lưu ý: Đây KHÔNG phải là khuyến nghị chính thức. Hãy tự đánh giá yêu cầu bảo mật của bạn trước khi sử dụng.
- Đã cài đặt Node.js 18+
- Đã cài đặt Claude Code CLI (
npm install -g @anthropic-ai/claude-code) - Đã đăng ký Alibaba Cloud Coding Plan
-
Truy cập Alibaba Cloud Coding Plan
-
Chọn gói đăng ký:
Gói Giá Giới hạn Lite $10/tháng 1,200 req/5hrs, 9,000/tuần, 18,000/tháng Pro $50/tháng 6,000 req/5hrs, 45,000/tuần, 90,000/tháng -
Các Model có sẵn:
Model Ghi chú glm-5Khuyên dùng cho coding - Tốc độ ổn định, reasoning tốt glm-4.7Phiên bản GLM khác qwen3.5-plusTổng quát qwen3-maxChỉ gói Pro, tác vụ nâng cao qwen3-coder-plusTối ưu cho code kimi-k2.5Context dài MiniMax-M2.5Model thay thế -
Hoàn tất đăng ký và lấy Coding Plan API Key (bắt đầu bằng
sk-sp-)
Mẹo: Một tác vụ đơn giản tốn ~5-10 lượt gọi, tác vụ phức tạp có thể tốn 10-30+ lượt. Khuyên dùng:
glm-5cho coding — tốc độ ổn định và reasoning tốt.
Cách tiếp cận hybrid để tiết kiệm chi phí:
| Tác vụ | Model Khuyên Dùng | Lý Do |
|---|---|---|
Planning (/rune:devise, /rune:forge, plan review) |
Claude Opus | Reasoning tốt hơn cho planning phức tạp |
Execution (/rune:strive, /rune:arc) |
glm-5 qua claude-ali |
Tiết kiệm chi phí khi chạy task |
| Testing, test-browser, agent browser | glm-5 qua claude-ali |
Hiệu suất ổn định cho tác vụ tự động |
Workflow:
- Dùng Claude Opus để tạo plan files (
/rune:devise,/rune:forge) - Chuyển sang
claude-alivớiglm-5để thực thi plan:/rune:strive plans/xxx.md— Thực thi plan đơn/rune:arc plans/xxx.md— Full pipeline (forge → work → review → mend → test)/rune:arc-batch plans/*.md— Thực thi nhiều plan cùng lúc
- Tiết kiệm đáng kể chi phí mà vẫn giữ được chất lượng
Cách tiếp cận hybrid này cho bạn tốt nhất của cả hai: chất lượng planning niveau Opus với chi phí thực thi thấp hơn nhiều.
| Vấn đề | Giải pháp |
|---|---|
| Chậm hơn Claude | Đánh đổi chấp nhận được cho chi phí thấp — lên kế hoạch phù hợp |
| Trả lời bằng tiếng Trung | Viết plan file bằng tiếng Trung để hiểu tốt hơn |
| Lệch khỏi plan | Dùng plan tiếng Trung để bám sát hơn |
Mẹo ngôn ngữ: Các model Trung Quốc như glm-5 thường hoạt động tốt hơn với input tiếng Trung. Nếu bạn biết tiếng Trung:
-
Phương án A: Viết plan file trực tiếp bằng tiếng Trung
-
Phương án B: Dùng Claude Sonnet để dịch plan tiếng Anh sang tiếng Trung trước khi thực thi:
# Dịch plan sang tiếng Trung với Claude Sonnet claude "Dịch plan này sang tiếng Trung để GLM-5 hiểu tốt hơn: $(cat plans/my-plan.md)" > plans/my-plan-zh.md # Thực thi với plan tiếng Trung claude-ali /rune:strive plans/my-plan-zh.md
Nhiều developer phản hồi rằng các model Trung Quốc bám sát plan tiếng Trung hơn và cho kết quả tốt hơn so với plan tiếng Anh.
npm install -g @musistudio/claude-code-routerTạo hoặc chỉnh sửa file ~/.claude-code-router/config.json:
{
"LOG": true,
"LOG_LEVEL": "debug",
"HOST": "127.0.0.1",
"PORT": 3456,
"API_TIMEOUT_MS": "600000",
"Providers": [
{
"name": "Alibaba Cloud",
"api_base_url": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1/messages",
"api_key": "${ALIBABA_CODING_PLAN_API_KEY}",
"models": ["glm-5"],
"transformer": {
"use": ["Anthropic"],
"glm-5": {
"use": ["Anthropic"]
}
}
}
],
"Router": {
"default": "Alibaba Cloud,glm-5",
"background": "Alibaba Cloud,glm-5",
"think": "Alibaba Cloud,glm-5",
"longContext": "Alibaba Cloud,glm-5",
"longContextThreshold": 60000
}
}Lưu ý: Sử dụng
coding-intl.dashscope.aliyuncs.com(endpoint quốc tế) và đường dẫn/apps/anthropic/v1/messagescho API tương thích Anthropic.
Thêm API key vào file cấu hình shell (~/.zshrc hoặc ~/.bashrc):
export ALIBABA_CODING_PLAN_API_KEY="sk-sp-api-key-của-bạn"Tải lại shell:
source ~/.zshrc # hoặc ~/.bashrcKhởi động router ở chế độ daemon:
ccr start --daemonMẹo: Nếu
ccr start --daemonbị lỗi, dùng alias sau thay thế:# Thêm vào ~/.zshrc hoặc ~/.bashrc alias ccrd='ccr start --daemon &' # Sau đó chạy ccrd
Hoặc khởi động Claude Code trực tiếp với router:
ccr codeCác lệnh hữu ích khác:
ccr model # Bộ chọn model tương tác
ccr ui # Giao diện cấu hình web
ccr preset # Quản lý preset cấu hình
ccr activate # Xuất biến môi trường cho shell
ccr restart # Khởi động lại sau khi thay đổi cấu hình
ccr stop # Dừng daemon
ccr status # Kiểm tra trạng thái router# Server logs
~/.claude-code-router/logs/ccr-*.log
# Application logs
~/.claude-code-router/claude-code-router.logSau khi cấu hình, tất cả lệnh Rune sẽ tự động chạy qua GLM-5:
# Ví dụ các lệnh Rune
/rune:appraise # Review code
/rune:devise # Lập kế hoạch
/rune:strive # Triển khai
/rune:audit # Audit toàn bộ codebaseVí dụ: /rune:audit chạy với 14 teammates trên GLM-5:
- Chỉ sử dụng cá nhân - Gói Coding Plan chỉ dành cho một người
- Không dùng cho script tự động - Chỉ sử dụng trong công cụ coding tương tác (Claude Code, OpenClaw)
- Sử dụng đúng endpoint - Luôn dùng
coding.dashscope.aliyuncs.com, KHÔNG phải endpoint Model Studio thông thường - Không hoàn tiền - Gói đăng ký không được hoàn tiền
| Vấn đề | Giải pháp |
|---|---|
ccr: command not found |
Kiểm tra PATH có chứa npm global bin: npm config get prefix |
401 Unauthorized |
Xác minh API key bắt đầu bằng sk-sp- và đã được thiết lập đúng |
Model not found |
Kiểm tra tên model: glm-5 (chữ thường) |
| Timeout kết nối | Kiểm tra mạng/proxy, xác minh api_base_url |
Tại sao chọn Z.AI thay Alibaba? Cài đặt đơn giản hơn (không cần router), API tương thích Anthropic trực tiếp, ít bị stuck khi chạy hơn.
- Truy cập Z.AI GLM Coding Plan
- Đăng ký (từ $10/tháng)
- Lấy API key tại z.ai/manage-apikey/apikey-list
Chỉnh sửa ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_MODEL": "GLM-4.7",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "GLM-4.7",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "GLM-4.7",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "GLM-4.5-Air",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": 1
}
}Không cần setup router. Chỉ cần chạy:
claude| Model | Dùng cho |
|---|---|
GLM-4.7 |
Khuyên dùng — Mặc định cho task Opus/Sonnet |
GLM-5 |
Model mới nhất — Tốt cho coding |
GLM-4.5-Air |
Nhanh, nhẹ — Mặc định cho task Haiku |
GLM-4.6V |
Vision tasks |
# macOS/Linux
curl -O "https://cdn.bigmodel.cn/install/claude_code_zai_env.sh" && bash ./claude_code_zai_env.sh
# Hoặc dùng helper
npx @z_ai/codinghelper| Vấn đề | Giải pháp |
|---|---|
| Config không có tác dụng | Đóng tất cả cửa sổ Claude Code và mở lại |
| Lỗi JSON | Kiểm tra với JSON validator online |
| Lỗi version | Chạy claude update để nâng cấp |
Hạn chế hiện tại: Agent teams (teammates) trong Claude Code không hoạt động tốt với cấu hình model tùy chỉnh trực tiếp. Ngay cả khi ANTHROPIC_MODEL đã được set, teammates vẫn có thể gọi Claude Opus hoặc Sonnet thay vì model tùy chỉnh của bạn.
Giải pháp khuyên dùng: Dùng claude-code-router (Phương án A) để hỗ trợ agent teams. Router sẽ chặn tất cả API calls, đảm bảo teammates sử dụng model đã cấu hình.
| Phương án Setup | Hỗ trợ Agent Teams | Ghi chú |
|---|---|---|
| Direct env config (Z.AI) | Teammates có thể bỏ qua model tùy chỉnh | |
| claude-code-router (Alibaba) | ✅ Hoạt động | Router ép model cho tất cả calls |
Đây là hạn chế đã biết và có thể sẽ được cải thiện trong các bản cập nhật Claude Code tương lai.
| Item | Value |
|---|---|
| API Key Prefix | sk-sp- |
| Base URL | https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1/messages |
| Transformer | Anthropic |
| Config File | ~/.claude-code-router/config.json |
| Start Command | ccr start --daemon |
| Code Command | ccr code |
| Model | Plan | Best For |
|---|---|---|
glm-5 |
Lite/Pro | Recommended for coding - Stable speed, good reasoning |
glm-4.7 |
Lite/Pro | Alternative GLM |
qwen3.5-plus |
Lite/Pro | General purpose |
qwen3-max |
Pro only | Advanced tasks |
qwen3-coder-plus |
Lite/Pro | Code optimization |
kimi-k2.5 |
Lite/Pro | Long context |
MiniMax-M2.5 |
Lite/Pro | Alternative |
Recommendation: Use
glm-5for coding tasks — it offers stable speed and solid reasoning capabilities for day-to-day development work.
Hybrid approach for cost efficiency:
| Task | Recommended Model | Why |
|---|---|---|
Planning (/rune:devise, /rune:forge, plan review) |
Claude Opus | Better reasoning for complex planning |
Execution (/rune:strive, /rune:arc) |
glm-5 via claude-ali |
Cost-effective for running tasks |
| Testing, test-browser, agent browser | glm-5 via claude-ali |
Stable performance for automated tasks |
Workflow:
- Use Claude Opus to create plan files (
/rune:devise,/rune:forge) - Switch to
claude-aliwithglm-5to execute the plan:/rune:strive plans/xxx.md— Single plan execution/rune:arc plans/xxx.md— Full pipeline (forge → work → review → mend → test)/rune:arc-batch plans/*.md— Batch execution of multiple plans
- Significant cost savings while maintaining quality
This hybrid approach gives you the best of both worlds: Opus-level planning quality at a fraction of the execution cost.
| Issue | Solution |
|---|---|
| Slower than Claude | Expected trade-off for lower cost — plan accordingly |
| Returns Chinese responses | Write plan files in Chinese for better comprehension |
| Deviates from plan | Use Chinese plans for tighter adherence |
Language tip: Chinese models like glm-5 often perform better with Chinese language input. If you know Chinese:
-
Option A: Write plan files directly in Chinese
-
Option B: Use Claude Sonnet to translate English plans to Chinese before execution:
# Translate plan to Chinese with Claude Sonnet claude "Translate this plan to Chinese for better GLM-5 comprehension: $(cat plans/my-plan.md)" > plans/my-plan-zh.md # Execute with Chinese plan claude-ali /rune:strive plans/my-plan-zh.md
Many developers report that Chinese models follow Chinese plans more closely and produce better results compared to English plans.
{
"Providers": [
{
"name": "Alibaba Cloud",
"api_base_url": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1/messages",
"api_key": "${ALIBABA_CODING_PLAN_API_KEY}",
"models": ["glm-5", "qwen3.5-plus", "qwen3-coder-plus", "kimi-k2.5"],
"transformer": {
"use": ["Anthropic"]
}
}
],
"Router": {
"default": "Alibaba Cloud,qwen3.5-plus",
"background": "Alibaba Cloud,glm-5",
"think": "Alibaba Cloud,qwen3.5-plus",
"longContext": "Alibaba Cloud,kimi-k2.5"
}
}If you want to use multiple Claude Code accounts (e.g., work + personal), create separate directories:
# 1. Create new Claude Code directory
mkdir -p ~/.claude-ali
# 2. Skip onboarding/setup
echo '{"hasCompletedProjectOnboarding": true}' > ~/.claude-ali/.claude.json
# 3. Configure Claude Code to use router
cat << 'EOF' > ~/.claude-ali/settings.json
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "anykey",
"ANTHROPIC_BASE_URL": "http://localhost:3456",
"ANTHROPIC_MODEL": "glm-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5",
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": 1
}
}
EOF
# 4. Router config (shared at HOME level)
vim ~/.claude-code-router/config.json# 1. Create new directory
mkdir -p ~/.claude-ali
# 2. Skip onboarding/setup
echo '{"hasCompletedProjectOnboarding": true}' > ~/.claude-ali/.claude.json
# 3. Configure Claude Code to use router
vim ~/.claude-ali/settings.json~/.claude-ali/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "anykey",
"ANTHROPIC_BASE_URL": "http://localhost:3456",
"ANTHROPIC_MODEL": "glm-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5",
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": 1
}
}Note: Router config is at
~/.claude-code-router/config.json(shared, HOME level), not inside~/.claude-ali/
Add to ~/.zshrc or ~/.bashrc:
# Alibaba GLM-5 account
alias claude-ali="CLAUDE_CONFIG_DIR=~/.claude-ali claude --dangerously-skip-permissions"
# Work account
alias claude-work="CLAUDE_CONFIG_DIR=~/.claude-work claude --dangerously-skip-permissions"
# Personal account
alias claude-personal="CLAUDE_CONFIG_DIR=~/.claude-personal claude --dangerously-skip-permissions"Then reload your shell:
source ~/.zshrc # or ~/.bashrcNow simply run:
claude-ali # Start Claude Code with Alibaba account
claude-work # Start Claude Code with work account
claude-personal # Start Claude Code with personal account~/
├── .claude-code-router/ # SHARED router config
│ └── config.json # Single config for all accounts
│
├── .claude/ # Default account
│ ├── .claude.json # Onboarding status
│ └── settings.json # Routes to router via env vars
│
├── .claude-ali/ # Alibaba Coding Plan
│ ├── .claude.json
│ └── settings.json # Routes to router via env vars
│
└── .claude-work/ # Work account
├── .claude.json
└── settings.json # Routes to router via env vars
Note: Router config (
~/.claude-code-router/config.json) is SHARED across all accounts. Each account'ssettings.jsonpoints to the router viaANTHROPIC_BASE_URL. The--dangerously-skip-permissionsflag skips permission prompts for a smoother experience.
