Skip to content

Commit c454d25

Browse files
committed
feat: add GLM one-shot setup
1 parent e31b639 commit c454d25

18 files changed

Lines changed: 382 additions & 41 deletions

NPM_README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ Multi-provider configuration for Claude Code Router with intelligent intent-base
88
## Quick Install
99

1010
```bash
11-
npm install -g claude-code-router-config
11+
npm install -g @halilertekin/claude-code-router-config
1212
ccr-setup
1313
```
1414

15+
### One-shot GLM setup (Claude login + GLM API)
16+
17+
```bash
18+
npx -y -p @halilertekin/claude-code-router-config ccr-glm-setup --key "YOUR_GLM_API_KEY"
19+
source ~/.zshrc
20+
glm
21+
```
22+
1523
## Features
1624

1725
- **🤖 7 AI Providers**: OpenAI, Anthropic, Gemini, Qwen, GLM, OpenRouter, GitHub Copilot
@@ -112,7 +120,7 @@ Inside Claude Code:
112120
/model anthropic,claude-sonnet-4-latest
113121
/model gemini,gemini-2.5-flash
114122
/model qwen,qwen-plus
115-
/model glm,glm-4.6
123+
/model glm,glm-4.7
116124
/model copilot,copilot
117125
```
118126

@@ -168,4 +176,4 @@ MIT © [Halil Ertekin](https://github.com/halilertekin)
168176

169177
---
170178

171-
**Note**: This is a configuration package. Requires the original [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router) to function.
179+
**Note**: This is a configuration package. Requires the original [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router) to function.

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ccr config template balanced # Best of all worlds
5555
| Deep analysis, architecture | Anthropic | claude-sonnet-4 |
5656
| Quick responses, summaries | Gemini | gemini-2.5-flash |
5757
| Simple tasks | Qwen | qwen-plus |
58-
| Translation, multilingual | GLM | glm-4.6 |
58+
| Translation, multilingual | GLM | glm-4.7 |
5959
| Complex algorithms | OpenAI | o1 |
6060
| Coding assistance | GitHub Copilot | copilot |
6161

@@ -66,6 +66,34 @@ ccr config template balanced # Best of all worlds
6666

6767
## Installation
6868

69+
### One-shot GLM setup (Claude login + GLM API)
70+
71+
If you only want GLM (Z.ai) inside Claude Code and keep your native Claude Pro login,
72+
run the single script below from this repo:
73+
74+
```bash
75+
./setup-glm.sh
76+
# or non-interactive:
77+
./setup-glm.sh --key "YOUR_GLM_API_KEY"
78+
```
79+
80+
Or run via npm without cloning:
81+
```bash
82+
npx -y -p @halilertekin/claude-code-router-config ccr-glm-setup --key "YOUR_GLM_API_KEY"
83+
```
84+
85+
This will:
86+
- Install `ccr` if missing (brew/pnpm/npm)
87+
- Write GLM-only config to `~/.claude-code-router/`
88+
- Store your key in `~/.claude-code-router/keys.env` (not `~/.env`)
89+
- Install a single command: `glm` (also `ccc` and `claude-glm`)
90+
91+
Then:
92+
```bash
93+
source ~/.zshrc
94+
glm
95+
```
96+
6997
### Option 1: Homebrew (Recommended for macOS)
7098

7199
> [!CAUTION]
@@ -214,7 +242,7 @@ Inside Claude Code:
214242
/model anthropic,claude-sonnet-4-latest
215243
/model gemini,gemini-2.5-flash
216244
/model qwen,qwen-plus
217-
/model glm,glm-4.6
245+
/model glm,glm-4.7
218246
/model copilot,copilot
219247
```
220248

@@ -334,4 +362,4 @@ MIT © [Halil Ertekin](https://github.com/halilertekin)
334362

335363
## 🌟 Show Your Support
336364

337-
If you find this useful, please give it a ⭐ on [GitHub](https://github.com/halilertekin/CC-RouterMultiProvider)!
365+
If you find this useful, please give it a ⭐ on [GitHub](https://github.com/halilertekin/CC-RouterMultiProvider)!

bin/ccr-glm-setup

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
exec "$SCRIPT_DIR/setup-glm.sh" "$@"

cli/analytics.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const PRICING = {
3636
'qwen3-coder-plus': { input: 2.0, output: 6.0 }
3737
},
3838
glm: {
39+
'glm-4.7': { input: 0.5, output: 2.0 },
3940
'glm-4.6': { input: 0.5, output: 2.0 },
4041
'glm-4.5': { input: 0.5, output: 2.0 },
4142
'glm-4-plus': { input: 1.0, output: 2.0 }
@@ -506,4 +507,4 @@ module.exports = {
506507
getAnalyticsSummary,
507508
exportAnalytics,
508509
calculateCost
509-
};
510+
};

config/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
},
3939
{
4040
"name": "glm",
41-
"api_base_url": "https://api.z.ai/api/paas/v4/chat/completions",
41+
"api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
4242
"api_key": "$GLM_API_KEY",
43-
"models": ["glm-4.6", "glm-4.5", "glm-4-plus"],
43+
"models": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-4-plus"],
4444
"transformer": { "use": [] }
4545
},
4646
{

config/glm-only.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"_comment": "Claude Code Router Configuration - GLM only (Z.ai Coding Plan)",
3+
"_author": "Configuration by Halil Ertekin",
4+
"LOG": true,
5+
"LOG_LEVEL": "info",
6+
"API_TIMEOUT_MS": 300000,
7+
"CUSTOM_ROUTER_PATH": "$HOME/.claude-code-router/intent-router.js",
8+
"PORT": 3456,
9+
10+
"Providers": [
11+
{
12+
"name": "glm",
13+
"api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
14+
"api_key": "$GLM_API_KEY",
15+
"models": [
16+
"glm-4.7",
17+
"glm-4.6",
18+
"glm-4.5",
19+
"glm-4.5-air",
20+
"glm-4.5-x",
21+
"glm-4.5-airx",
22+
"glm-4.5-flash",
23+
"glm-4-32b-0414-128k"
24+
],
25+
"transformer": { "use": [] }
26+
}
27+
],
28+
29+
"Router": {
30+
"default": "glm,glm-4.7",
31+
"background": "glm,glm-4.7",
32+
"think": "glm,glm-4.7",
33+
"longContext": "glm,glm-4.7",
34+
"longContextThreshold": 60000
35+
}
36+
}

config/intent-router-glm.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* GLM-only Intent Router
3+
* Forces all traffic to GLM-4.7
4+
*/
5+
6+
module.exports = async function router(_req, _config) {
7+
return "glm,glm-4.7";
8+
};

config/intent-router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const INTENTS = {
5656
/[\u4e00-\u9fff]/, // Chinese characters
5757
/[\u0600-\u06FF]/, // Arabic
5858
],
59-
route: "glm,glm-4.6"
59+
route: "glm,glm-4.7"
6060
},
6161

6262
// Heavy coding/reasoning → O1

config/smart-intent-router.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const INTENTS = {
8686
],
8787
route: "gemini,gemini-2.5-flash",
8888
strategy: "performance",
89-
fallbacks: ["qwen,qwen-turbo", "glm,glm-4.5"],
89+
fallbacks: ["qwen,qwen-turbo", "glm,glm-4.7"],
9090
priority: "medium"
9191
},
9292

@@ -99,7 +99,7 @@ const INTENTS = {
9999
],
100100
route: "qwen,qwen-plus",
101101
strategy: "cost",
102-
fallbacks: ["glm,glm-4.5", "gemini,gemini-2.5-flash"],
102+
fallbacks: ["glm,glm-4.7", "gemini,gemini-2.5-flash"],
103103
priority: "low"
104104
},
105105

@@ -110,7 +110,7 @@ const INTENTS = {
110110
/[\u4e00-\u9fff]/, // Chinese characters
111111
/[\u0600-\u06FF]/, // Arabic
112112
],
113-
route: "glm,glm-4.6",
113+
route: "glm,glm-4.7",
114114
strategy: "quality",
115115
fallbacks: ["qwen,qwen-plus", "gemini,gemini-2.5-flash"],
116116
priority: "medium"
@@ -203,6 +203,7 @@ const PROVIDER_PROFILES = {
203203
speedTier: "high",
204204
specialties: ["chinese", "multilingual", "translation"],
205205
models: {
206+
"glm-4.7": { cost: 0.1, speed: 2, quality: 0.8, capability: "multilingual" },
206207
"glm-4.6": { cost: 0.1, speed: 2, quality: 0.8, capability: "multilingual" },
207208
"glm-4.5": { cost: 0.1, speed: 2, quality: 0.8, capability: "multilingual" },
208209
"glm-4-plus": { cost: 0.2, speed: 1.5, quality: 0.9, capability: "general" }
@@ -540,4 +541,4 @@ function updateRoutingMetrics(metrics, intent, selected, latency) {
540541
// Export utilities for testing
541542
module.exports.INTENTS = INTENTS;
542543
module.exports.PROVIDER_PROFILES = PROVIDER_PROFILES;
543-
module.exports.ROUTING_STRATEGIES = ROUTING_STRATEGIES;
544+
module.exports.ROUTING_STRATEGIES = ROUTING_STRATEGIES;

docs/FULL_DOCUMENTATION.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ Claude Code Router, Claude Code CLI'ı bir proxy üzerinden çalıştırarak ist
107107
### 5. Zhipu GLM (Z.ai)
108108
| Özellik | Değer |
109109
|---------|-------|
110-
| **API URL** | `https://api.z.ai/api/paas/v4/chat/completions` |
111-
| **Modeller** | glm-4.6, glm-4.5, glm-4-plus |
110+
| **API URL** | `https://api.z.ai/api/coding/paas/v4/chat/completions` |
111+
| **Modeller** | glm-4.7, glm-4.6, glm-4.5, glm-4-plus |
112112
| **Kullanım** | Çok dilli, Çince, çeviri |
113113
| **Maliyet** | Düşük |
114114
| **Env Var** | `GLM_API_KEY` |
@@ -135,7 +135,7 @@ Claude Code Router, Claude Code CLI'ı bir proxy üzerinden çalıştırarak ist
135135
| **REASONING** | architect, design, analyze, plan, why, explain, compare, evaluate, best practice | Anthropic | claude-sonnet-4 |
136136
| **FAST** | fast, quick, brief, summary, tldr, overview, hızlı, scan, check | Gemini | gemini-2.5-flash |
137137
| **SIMPLE** | list, show, what is, simple, basic, help, format, rename, mkdir, ucuz, basit | Qwen | qwen-plus |
138-
| **MULTILINGUAL** | translate, çevir, tercüme, chinese, türkçe, Çince karakterler | GLM | glm-4.6 |
138+
| **MULTILINGUAL** | translate, çevir, tercüme, chinese, türkçe, Çince karakterler | GLM | glm-4.7 |
139139
| **HEAVY_REASONING** | complex algorithm, optimization, performance critical, prove, mathematical | OpenAI | o1 |
140140

141141
### Built-in Router Ayarları
@@ -341,7 +341,7 @@ Claude Code içinde `/model` komutu:
341341
/model gemini,gemini-2.5-pro
342342
/model qwen,qwen-plus
343343
/model qwen,qwen3-coder-plus
344-
/model glm,glm-4.6
344+
/model glm,glm-4.7
345345
/model openrouter,deepseek/deepseek-chat
346346
```
347347

0 commit comments

Comments
 (0)