@halilertekin/claude-code-router-config 1.3.5 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NPM_README.md CHANGED
@@ -8,10 +8,18 @@ Multi-provider configuration for Claude Code Router with intelligent intent-base
8
8
  ## Quick Install
9
9
 
10
10
  ```bash
11
- npm install -g claude-code-router-config
11
+ npm install -g @halilertekin/claude-code-router-config
12
12
  ccr-setup
13
13
  ```
14
14
 
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
+
15
23
  ## Features
16
24
 
17
25
  - **🤖 7 AI Providers**: OpenAI, Anthropic, Gemini, Qwen, GLM, OpenRouter, GitHub Copilot
@@ -112,7 +120,7 @@ Inside Claude Code:
112
120
  /model anthropic,claude-sonnet-4-latest
113
121
  /model gemini,gemini-2.5-flash
114
122
  /model qwen,qwen-plus
115
- /model glm,glm-4.6
123
+ /model glm,glm-4.7
116
124
  /model copilot,copilot
117
125
  ```
118
126
 
@@ -168,4 +176,4 @@ MIT © [Halil Ertekin](https://github.com/halilertekin)
168
176
 
169
177
  ---
170
178
 
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.
package/README.md CHANGED
@@ -1,40 +1,46 @@
1
1
  # Claude Code Router Config - Advanced Multi-Provider Setup
2
2
 
3
- 🚀 **v1.1.0** - Now with advanced CLI tools, analytics, smart routing, and configuration templates!
3
+ 🚀 **v1.3.7** - Now with z.ai (GLM 4.7) support, advanced CLI tools, analytics, smart routing, and configuration templates!
4
4
 
5
5
  Use Claude Code as a single interface to access multiple AI providers with intelligent routing for optimal performance, cost, and quality.
6
6
 
7
- ## ✨ New Features in v1.1.0
7
+ ## ✨ New in v1.3.7
8
+ - **z.ai Support**: Native integration for GLM-4.7 via z.ai (PPInfra).
9
+ - **Lightweight Mode**: New `ccc` function for zero-dependency routing.
10
+ - **Direct GLM Alias**: Type `glm` to launch Claude Code with GLM-4.7 immediately.
11
+
12
+ ## 🚀 Setup on Another Machine (Fastest Way)
13
+
14
+ If you just want to use the `ccc` command (Claude Code Commander) and `glm` alias without installing the full Node.js router stack:
15
+
16
+ 1. **Clone the repo:**
17
+ ```bash
18
+ mkdir -p ~/code
19
+ git clone git@github.com:halilertekin/CC-RouterMultiProvider.git ~/code/claude-code-router-config
20
+ ```
21
+
22
+ 2. **Source the script in your `.zshrc`:**
23
+ Add this line to your `~/.zshrc`:
24
+ ```bash
25
+ [[ -f "$HOME/code/claude-code-router-config/cli/ccc.zsh" ]] && source "$HOME/code/claude-code-router-config/cli/ccc.zsh"
26
+ ```
27
+
28
+ 3. **Configure Keys:**
29
+ Create `~/.env` or `~/.ccm_config` with your keys:
30
+ ```bash
31
+ export GLM_API_KEY="your_zai_key_here"
32
+ export DEEPSEEK_API_KEY="your_deepseek_key_here"
33
+ ```
34
+
35
+ 4. **Reload & Run:**
36
+ ```bash
37
+ source ~/.zshrc
38
+ glm # Launches GLM-4.7 via z.ai
39
+ ccc ds # Launches DeepSeek
40
+ ccc claude # Launches Official Claude (Pro)
41
+ ```
8
42
 
9
- ### 🛠️ Advanced CLI Tools
10
- ```bash
11
- ccr test <provider> [model] # Test provider connectivity
12
- ccr benchmark --compare-speed # Benchmark all providers
13
- ccr analytics today # View usage statistics
14
- ccr config validate # Validate configuration
15
- ccr health --all-providers # Check provider health
16
- ```
17
-
18
- ### 📊 Analytics & Monitoring
19
- - **Cost Tracking**: Monitor spending per provider and model
20
- - **Usage Analytics**: Track requests, latency, and success rates
21
- - **Performance Metrics**: Detailed performance insights
22
- - **Health Monitoring**: Real-time provider health checks
23
-
24
- ### 🧠 Smart Routing Engine
25
- - **Adaptive Routing**: Learns from past performance
26
- - **Cost-Aware Selection**: Optimizes for budget constraints
27
- - **Performance-Based**: Prioritizes speed when needed
28
- - **Quality-Focused**: Ensures best results for critical tasks
29
-
30
- ### 📋 Configuration Templates
31
- ```bash
32
- ccr config template performance-optimized # Speed prioritized
33
- ccr config template cost-optimized # Budget friendly
34
- ccr config template quality-focused # Maximum quality
35
- ccr config template development # Coding optimized
36
- ccr config template balanced # Best of all worlds
37
- ```
43
+ ---
38
44
 
39
45
  ## Features
40
46
 
@@ -55,47 +61,22 @@ ccr config template balanced # Best of all worlds
55
61
  | Deep analysis, architecture | Anthropic | claude-sonnet-4 |
56
62
  | Quick responses, summaries | Gemini | gemini-2.5-flash |
57
63
  | Simple tasks | Qwen | qwen-plus |
58
- | Translation, multilingual | GLM | glm-4.6 |
64
+ | Translation, multilingual | GLM | glm-4.7 (z.ai) |
59
65
  | Complex algorithms | OpenAI | o1 |
60
66
  | Coding assistance | GitHub Copilot | copilot |
61
67
 
62
- ## Requirements
63
-
64
- - **Node.js**: >= 16.0.0
65
- - **Package Manager**: pnpm (preferred) or npm
66
-
67
- ## Installation
68
-
69
- ### Option 1: Homebrew (Recommended for macOS)
70
-
71
- > [!CAUTION]
72
- > **Conflict Warning**: Do NOT install using both Homebrew and PNPM/NPM simultaneously. Choose only ONE method to avoid command conflicts.
73
-
74
- The easiest way to install and keep updated on macOS.
75
-
76
- ```bash
77
- brew uninstall ccr # Remove old versions if present
78
- brew install halilertekin/tap/claude-code-router-config
79
- ```
80
-
81
- After installation, edit your API keys in `~/.env` and start the router:
82
- ```bash
83
- ccr code
84
- ```
85
-
86
- ### Option 2: PNPM (Alternative)
68
+ ## Installation (Full Router)
87
69
 
88
- Use this if you are on Linux or prefer using a Node package manager.
70
+ ### Option 1: PNPM (Recommended)
89
71
 
90
- > [!WARNING]
91
- > If you have previously installed via Homebrew, please uninstall it first: `brew uninstall claude-code-router-config`
72
+ Use this if you want the full routing capabilities (benchmarking, analytics, etc).
92
73
 
93
74
  ```bash
94
75
  pnpm add -g @halilertekin/claude-code-router-config
95
76
  # System is ready! Run: ccr --help
96
77
  ```
97
78
 
98
- ### Option 3: Manual Setup
79
+ ### Option 2: Manual Setup
99
80
 
100
81
  #### 1. Install Dependencies
101
82
 
@@ -120,23 +101,6 @@ cp .env.example ~/.env
120
101
  # Edit ~/.env with your API keys
121
102
  ```
122
103
 
123
- Or add to `~/.zshrc` / `~/.bashrc`:
124
-
125
- ```bash
126
- # Claude Code Router - API Keys
127
- export OPENAI_API_KEY="sk-..."
128
- export ANTHROPIC_API_KEY="sk-ant-..."
129
- export GEMINI_API_KEY="AIza..."
130
- export QWEN_API_KEY="sk-..."
131
- export GLM_API_KEY="..."
132
- export OPENROUTER_API_KEY="sk-or-..."
133
- export GITHUB_COPIOT_API_KEY="ghu_..."
134
-
135
- # Router Connection
136
- export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
137
- export NO_PROXY="127.0.0.1"
138
- ```
139
-
140
104
  #### 4. Start Router
141
105
 
142
106
  ```bash
@@ -144,80 +108,6 @@ source ~/.zshrc
144
108
  ccr code
145
109
  ```
146
110
 
147
- ## Usage
148
-
149
- ### 🔧 Advanced CLI Commands
150
-
151
- #### Testing & Benchmarking
152
- ```bash
153
- # Test provider connectivity
154
- ccr test openai gpt-4o
155
- ccr test anthropic claude-sonnet-4-latest
156
-
157
- # Benchmark all providers
158
- ccr benchmark --all --compare-speed
159
- ccr benchmark full 5 --provider=openai --provider=anthropic
160
-
161
- # Load testing
162
- ccr benchmark load openai gpt-4o --concurrent=5 --duration=30
163
- ```
164
-
165
- #### Configuration Management
166
- ```bash
167
- # Validate configuration
168
- ccr config validate
169
-
170
- # Backup configuration
171
- ccr config backup
172
-
173
- # Apply templates
174
- ccr config template performance-optimized
175
- ccr config template cost-optimized
176
- ccr config template quality-focused
177
- ccr config template development
178
- ccr config template balanced
179
-
180
- # Show detailed status with costs
181
- ccr status --detailed --show-costs
182
- ```
183
-
184
- #### Analytics & Monitoring
185
- ```bash
186
- # View today's analytics
187
- ccr analytics today --detailed
188
-
189
- # View period analytics
190
- ccr analytics week --detailed
191
- ccr analytics month --detailed
192
-
193
- # Export data
194
- ccr analytics export --format=csv --period=month
195
-
196
- # Health monitoring
197
- ccr health --all-providers
198
- ```
199
-
200
- ### Basic Commands
201
-
202
- ```bash
203
- ccr start # Start router
204
- ccr code # Start with Claude Code
205
- ccr stop # Stop router
206
- ```
207
-
208
- ### Switch Models (Runtime)
209
-
210
- Inside Claude Code:
211
-
212
- ```
213
- /model openai,gpt-4o
214
- /model anthropic,claude-sonnet-4-latest
215
- /model gemini,gemini-2.5-flash
216
- /model qwen,qwen-plus
217
- /model glm,glm-4.6
218
- /model copilot,copilot
219
- ```
220
-
221
111
  ## API Key Setup
222
112
 
223
113
  | Provider | Link | Notes |
@@ -226,22 +116,10 @@ Inside Claude Code:
226
116
  | Anthropic | https://console.anthropic.com/settings/keys | Claude models |
227
117
  | Gemini | https://aistudio.google.com/apikey | Google AI models |
228
118
  | Qwen | https://dashscope.console.aliyun.com/apiKey | Alibaba Cloud |
229
- | GLM | https://open.bigmodel.cn/usercenter/apikeys | Zhipu AI |
119
+ | GLM (z.ai) | https://open.bigmodel.cn/usercenter/apikeys | Zhipu AI / z.ai |
230
120
  | OpenRouter | https://openrouter.ai/keys | Multiple models |
231
121
  | GitHub Copilot | https://github.com/settings/tokens | `copilot` scope |
232
122
 
233
- ## Testing
234
-
235
- ```bash
236
- # Test different routing scenarios
237
- claude "Write a Python sorting function" # → OpenAI
238
- claude "Explain microservices architecture" # → Anthropic
239
- claude "Quick summary of REST APIs" # → Gemini
240
- claude "List files in current directory" # → Qwen
241
- claude "Translate to Chinese: Hello" # → GLM
242
- claude "Help me debug this React component" # → GitHub Copilot
243
- ```
244
-
245
123
  ## Configuration Templates
246
124
 
247
125
  | Template | Best For | Priority | Cost | Speed |
@@ -259,23 +137,6 @@ ccr config template cost-optimized # Cheapest
259
137
  ccr config template quality-focused # Best quality
260
138
  ```
261
139
 
262
- ## Smart Routing Features
263
-
264
- ### 🧠 Adaptive Intelligence
265
- - **Learning**: Improves routing based on historical performance
266
- - **Context Awareness**: Considers request complexity and timing
267
- - **Cost Awareness**: Respects budget constraints and optimization goals
268
-
269
- ### 🔄 Auto-Fallback
270
- - **Health Checks**: Monitors provider status every 30 seconds
271
- - **Circuit Breaker**: Automatically routes around failed providers
272
- - **Graceful Degradation**: Maintains service during provider issues
273
-
274
- ### 📈 Performance Optimization
275
- - **Latency Tracking**: Monitors and optimizes for speed
276
- - **Success Rate**: Reliability-based routing decisions
277
- - **Load Balancing**: Distributes requests optimally
278
-
279
140
  ## Analytics Dashboard
280
141
 
281
142
  View comprehensive analytics via:
@@ -302,22 +163,6 @@ Metrics tracked:
302
163
  - [Setup Prompt (TR)](docs/SETUP_PROMPT.md)
303
164
  - [Configuration Templates Guide](templates/README.md)
304
165
 
305
- ## What's New
306
-
307
- ### v1.1.0 Features
308
- - ✨ Advanced CLI tools for testing and benchmarking
309
- - 📊 Built-in analytics and cost tracking
310
- - 🧠 Smart routing with machine learning
311
- - 📋 Configuration templates for different use cases
312
- - 🔍 Health monitoring and auto-fallback
313
- - 📝 Enhanced logging with metrics
314
-
315
- ### Coming Soon
316
- - 🌐 Enhanced web dashboard
317
- - 🔌 Plugin system for custom providers
318
- - 🤖 AI-powered optimization recommendations
319
- - 📱 Mobile-friendly analytics dashboard
320
-
321
166
  ## Attribution
322
167
 
323
168
  This package provides configuration for [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router), an excellent tool that enables Claude Code functionality with multiple AI providers.
@@ -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" "$@"
package/cli/analytics.js CHANGED
@@ -36,6 +36,7 @@ const PRICING = {
36
36
  'qwen3-coder-plus': { input: 2.0, output: 6.0 }
37
37
  },
38
38
  glm: {
39
+ 'glm-4.7': { input: 0.5, output: 2.0 },
39
40
  'glm-4.6': { input: 0.5, output: 2.0 },
40
41
  'glm-4.5': { input: 0.5, output: 2.0 },
41
42
  'glm-4-plus': { input: 1.0, output: 2.0 }
@@ -506,4 +507,4 @@ module.exports = {
506
507
  getAnalyticsSummary,
507
508
  exportAnalytics,
508
509
  calculateCost
509
- };
510
+ };
package/cli/ccc.zsh ADDED
@@ -0,0 +1,75 @@
1
+ #!/bin/zsh
2
+
3
+ # Claude Code Router (Modern replacement for ccm/ccc)
4
+ # Source this file in your .zshrc: source ~/code/claude-code-router-config/cli/ccc.zsh
5
+
6
+ ccc() {
7
+ local model_alias="${1:-claude}"
8
+ shift 1 2>/dev/null
9
+ local extra_args=("$@")
10
+
11
+ # Load keys from multiple sources for redundancy
12
+ [[ -f ~/.ccm_config ]] && source ~/.ccm_config 2>/dev/null
13
+ [[ -f ~/.env ]] && source ~/.env 2>/dev/null
14
+
15
+ # 1. CLEANUP: Remove all env vars that might interfere with Claude Pro
16
+ unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY ANTHROPIC_MODEL ANTHROPIC_AUTH_TOKEN API_TIMEOUT_MS
17
+ unset ANTHROPIC_DEFAULT_SONNET_MODEL ANTHROPIC_DEFAULT_OPUS_MODEL ANTHROPIC_DEFAULT_HAIKU_MODEL
18
+
19
+ # 2. CONFIGURATION based on alias
20
+ case "$model_alias" in
21
+ glm|zhipu|zai|pp|zero)
22
+ # z.ai / GLM 4.7 configuration
23
+ export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
24
+ # Priority: 1. ENV, 2. PP_KEY (config), 3. GLM_KEY (config)
25
+ export ANTHROPIC_API_KEY="${GLM_API_KEY:-${PPINFRA_API_KEY:-$GLM_KEY}}"
26
+ export ANTHROPIC_AUTH_TOKEN="$ANTHROPIC_API_KEY"
27
+ export ANTHROPIC_MODEL="glm-4.7"
28
+ export API_TIMEOUT_MS=3000000
29
+
30
+ # Force mappings for z.ai
31
+ export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-4.7"
32
+ export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-4.7"
33
+ export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-4.5-air"
34
+
35
+ echo "🔄 Provider: z.ai (GLM 4.7)"
36
+ ;;
37
+
38
+ ds|deepseek)
39
+ # Deepseek configuration
40
+ export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
41
+ export ANTHROPIC_API_KEY="${DEEPSEEK_API_KEY:-$DS_KEY}"
42
+ export ANTHROPIC_AUTH_TOKEN="$ANTHROPIC_API_KEY"
43
+ export ANTHROPIC_MODEL="deepseek-chat"
44
+ export API_TIMEOUT_MS=600000
45
+
46
+ echo "🔄 Provider: DeepSeek"
47
+ ;;
48
+
49
+ claude)
50
+ # Official Claude (Pro Subscription)
51
+ export ANTHROPIC_MODEL="claude-sonnet-4-5-20250929"
52
+ echo "🔄 Provider: Official Anthropic (Claude Pro)"
53
+ ;;
54
+
55
+ *)
56
+ echo "Unknown model alias: $model_alias"
57
+ echo "Available: glm, ds, claude"
58
+ return 1
59
+ ;;
60
+ esac
61
+
62
+ echo "🚀 Launching Claude Code..."
63
+ [[ -n "$ANTHROPIC_BASE_URL" ]] && echo "🌐 Base URL: $ANTHROPIC_BASE_URL"
64
+
65
+ if [[ ${#extra_args[@]} -eq 0 ]]; then
66
+ exec claude
67
+ else
68
+ exec claude "${extra_args[@]}"
69
+ fi
70
+ }
71
+
72
+ # Shortcuts
73
+ alias glm="ccc glm"
74
+ alias deepseek="ccc ds"
75
+ alias claude-pro="ccc claude"
@@ -38,9 +38,9 @@
38
38
  },
39
39
  {
40
40
  "name": "glm",
41
- "api_base_url": "https://api.z.ai/api/paas/v4/chat/completions",
41
+ "api_base_url": "https://api.z.ai/api/anthropic",
42
42
  "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"],
44
44
  "transformer": { "use": [] }
45
45
  },
46
46
  {
@@ -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/anthropic",
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
+ }
@@ -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
+ };
@@ -56,7 +56,7 @@ const INTENTS = {
56
56
  /[\u4e00-\u9fff]/, // Chinese characters
57
57
  /[\u0600-\u06FF]/, // Arabic
58
58
  ],
59
- route: "glm,glm-4.6"
59
+ route: "glm,glm-4.7"
60
60
  },
61
61
 
62
62
  // Heavy coding/reasoning → O1
@@ -86,7 +86,7 @@ const INTENTS = {
86
86
  ],
87
87
  route: "gemini,gemini-2.5-flash",
88
88
  strategy: "performance",
89
- fallbacks: ["qwen,qwen-turbo", "glm,glm-4.5"],
89
+ fallbacks: ["qwen,qwen-turbo", "glm,glm-4.7"],
90
90
  priority: "medium"
91
91
  },
92
92
 
@@ -99,7 +99,7 @@ const INTENTS = {
99
99
  ],
100
100
  route: "qwen,qwen-plus",
101
101
  strategy: "cost",
102
- fallbacks: ["glm,glm-4.5", "gemini,gemini-2.5-flash"],
102
+ fallbacks: ["glm,glm-4.7", "gemini,gemini-2.5-flash"],
103
103
  priority: "low"
104
104
  },
105
105
 
@@ -110,7 +110,7 @@ const INTENTS = {
110
110
  /[\u4e00-\u9fff]/, // Chinese characters
111
111
  /[\u0600-\u06FF]/, // Arabic
112
112
  ],
113
- route: "glm,glm-4.6",
113
+ route: "glm,glm-4.7",
114
114
  strategy: "quality",
115
115
  fallbacks: ["qwen,qwen-plus", "gemini,gemini-2.5-flash"],
116
116
  priority: "medium"
@@ -203,6 +203,7 @@ const PROVIDER_PROFILES = {
203
203
  speedTier: "high",
204
204
  specialties: ["chinese", "multilingual", "translation"],
205
205
  models: {
206
+ "glm-4.7": { cost: 0.1, speed: 2, quality: 0.8, capability: "multilingual" },
206
207
  "glm-4.6": { cost: 0.1, speed: 2, quality: 0.8, capability: "multilingual" },
207
208
  "glm-4.5": { cost: 0.1, speed: 2, quality: 0.8, capability: "multilingual" },
208
209
  "glm-4-plus": { cost: 0.2, speed: 1.5, quality: 0.9, capability: "general" }
@@ -540,4 +541,4 @@ function updateRoutingMetrics(metrics, intent, selected, latency) {
540
541
  // Export utilities for testing
541
542
  module.exports.INTENTS = INTENTS;
542
543
  module.exports.PROVIDER_PROFILES = PROVIDER_PROFILES;
543
- module.exports.ROUTING_STRATEGIES = ROUTING_STRATEGIES;
544
+ module.exports.ROUTING_STRATEGIES = ROUTING_STRATEGIES;
@@ -107,8 +107,8 @@ Claude Code Router, Claude Code CLI'ı bir proxy üzerinden çalıştırarak ist
107
107
  ### 5. Zhipu GLM (Z.ai)
108
108
  | Özellik | Değer |
109
109
  |---------|-------|
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 |
112
112
  | **Kullanım** | Çok dilli, Çince, çeviri |
113
113
  | **Maliyet** | Düşük |
114
114
  | **Env Var** | `GLM_API_KEY` |
@@ -135,7 +135,7 @@ Claude Code Router, Claude Code CLI'ı bir proxy üzerinden çalıştırarak ist
135
135
  | **REASONING** | architect, design, analyze, plan, why, explain, compare, evaluate, best practice | Anthropic | claude-sonnet-4 |
136
136
  | **FAST** | fast, quick, brief, summary, tldr, overview, hızlı, scan, check | Gemini | gemini-2.5-flash |
137
137
  | **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 |
139
139
  | **HEAVY_REASONING** | complex algorithm, optimization, performance critical, prove, mathematical | OpenAI | o1 |
140
140
 
141
141
  ### Built-in Router Ayarları
@@ -341,7 +341,7 @@ Claude Code içinde `/model` komutu:
341
341
  /model gemini,gemini-2.5-pro
342
342
  /model qwen,qwen-plus
343
343
  /model qwen,qwen3-coder-plus
344
- /model glm,glm-4.6
344
+ /model glm,glm-4.7
345
345
  /model openrouter,deepseek/deepseek-chat
346
346
  ```
347
347
 
@@ -107,8 +107,8 @@ Claude Code Router acts as a proxy that intercepts Claude Code CLI requests and
107
107
  ### 5. Zhipu GLM (Z.ai)
108
108
  | Feature | Value |
109
109
  |---------|-------|
110
- | **API URL** | `https://api.z.ai/api/paas/v4/chat/completions` |
111
- | **Models** | glm-4.6, glm-4.5, glm-4-plus |
110
+ | **API URL** | `https://api.z.ai/api/coding/paas/v4/chat/completions` |
111
+ | **Models** | glm-4.7, glm-4.6, glm-4.5, glm-4-plus |
112
112
  | **Use Case** | Multilingual, Chinese, translation |
113
113
  | **Cost** | Low |
114
114
  | **Env Var** | `GLM_API_KEY` |
@@ -144,7 +144,7 @@ Claude Code Router acts as a proxy that intercepts Claude Code CLI requests and
144
144
  | **REASONING** | architect, design, analyze, plan, why, explain, compare, evaluate, best practice | Anthropic | claude-sonnet-4 |
145
145
  | **FAST** | fast, quick, brief, summary, tldr, overview, scan, check | Gemini | gemini-2.5-flash |
146
146
  | **SIMPLE** | list, show, what is, simple, basic, help, format, rename, mkdir | Qwen | qwen-plus |
147
- | **MULTILINGUAL** | translate, translate, multilingual, Chinese characters | GLM | glm-4.6 |
147
+ | **MULTILINGUAL** | translate, translate, multilingual, Chinese characters | GLM | glm-4.7 |
148
148
  | **HEAVY_REASONING** | complex algorithm, optimization, performance critical, prove, mathematical | OpenAI | o1 |
149
149
  | **CODING_ASSIST** | help me code, fix this error, suggest improvement, refactor | GitHub Copilot | copilot |
150
150
 
@@ -346,7 +346,7 @@ Inside Claude Code using `/model` command:
346
346
  /model gemini,gemini-2.5-pro
347
347
  /model qwen,qwen-plus
348
348
  /model qwen,qwen3-coder-plus
349
- /model glm,glm-4.6
349
+ /model glm,glm-4.7
350
350
  /model openrouter,deepseek/deepseek-chat
351
351
  /model copilot,copilot
352
352
  ```
@@ -523,4 +523,4 @@ The original Claude Code Router project is developed and maintained by musistudi
523
523
  - [Gemini API Docs](https://ai.google.dev/gemini-api/docs)
524
524
  - [DashScope Docs](https://www.alibabacloud.com/help/en/model-studio)
525
525
  - [Z.ai Docs](https://docs.z.ai)
526
- - [GitHub Copilot API](https://docs.github.com/en/copilot)
526
+ - [GitHub Copilot API](https://docs.github.com/en/copilot)
package/docs/README_EN.md CHANGED
@@ -17,7 +17,7 @@ Use Claude Code as a single interface to access multiple AI providers with inten
17
17
  | Deep analysis, architecture | Anthropic | claude-sonnet-4 |
18
18
  | Quick responses, summaries | Gemini | gemini-2.5-flash |
19
19
  | Simple tasks | Qwen | qwen-plus |
20
- | Translation, multilingual | GLM | glm-4.6 |
20
+ | Translation, multilingual | GLM | glm-4.7 |
21
21
  | Complex algorithms | OpenAI | o1 |
22
22
  | Coding assistance | GitHub Copilot | copilot |
23
23
 
@@ -30,6 +30,12 @@ chmod +x install.sh
30
30
  ./install.sh
31
31
  ```
32
32
 
33
+ ### One-shot GLM setup (Claude login + GLM API)
34
+
35
+ ```bash
36
+ ./setup-glm.sh --key "YOUR_GLM_API_KEY"
37
+ ```
38
+
33
39
  ## Manual Setup
34
40
 
35
41
  ### 1. Install Package
@@ -99,7 +105,7 @@ Inside Claude Code:
99
105
  /model anthropic,claude-sonnet-4-latest
100
106
  /model gemini,gemini-2.5-flash
101
107
  /model qwen,qwen-plus
102
- /model glm,glm-4.6
108
+ /model glm,glm-4.7
103
109
  /model copilot,copilot
104
110
  ```
105
111
 
@@ -143,4 +149,4 @@ claude "Help me debug this React component" # → GitHub Copilot
143
149
 
144
150
  ## License
145
151
 
146
- MIT
152
+ MIT
@@ -45,7 +45,7 @@ API Endpoint'leri:
45
45
  - Anthropic: https://api.anthropic.com/v1/messages (transformer: Anthropic)
46
46
  - Gemini: https://generativelanguage.googleapis.com/v1beta/openai/chat/completions (transformer: gemini)
47
47
  - Qwen: https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions
48
- - GLM: https://api.z.ai/api/paas/v4/chat/completions
48
+ - GLM: https://api.z.ai/api/coding/paas/v4/chat/completions
49
49
  - OpenRouter: https://openrouter.ai/api/v1/chat/completions (transformer: openrouter)
50
50
 
51
51
  Router Ayarları:
@@ -117,9 +117,9 @@ cat > ~/.claude-code-router/config.json << 'EOF'
117
117
  },
118
118
  {
119
119
  "name": "glm",
120
- "api_base_url": "https://api.z.ai/api/paas/v4/chat/completions",
120
+ "api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
121
121
  "api_key": "$GLM_API_KEY",
122
- "models": ["glm-4.6", "glm-4.5", "glm-4-plus"],
122
+ "models": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-4-plus"],
123
123
  "transformer": { "use": [] }
124
124
  },
125
125
  {
@@ -190,7 +190,7 @@ const INTENTS = {
190
190
  /[\u4e00-\u9fff]/,
191
191
  /[\u0600-\u06FF]/,
192
192
  ],
193
- route: "glm,glm-4.6"
193
+ route: "glm,glm-4.7"
194
194
  },
195
195
  HEAVY_REASONING: {
196
196
  patterns: [
@@ -46,7 +46,7 @@ API Endpoints:
46
46
  - Anthropic: https://api.anthropic.com/v1/messages (transformer: Anthropic)
47
47
  - Gemini: https://generativelanguage.googleapis.com/v1beta/openai/chat/completions (transformer: gemini)
48
48
  - Qwen: https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions
49
- - GLM: https://api.z.ai/api/paas/v4/chat/completions
49
+ - GLM: https://api.z.ai/api/coding/paas/v4/chat/completions
50
50
  - OpenRouter: https://openrouter.ai/api/v1/chat/completions (transformer: openrouter)
51
51
  - GitHub Copilot: Custom implementation for GitHub API
52
52
 
@@ -119,9 +119,9 @@ cat > ~/.claude-code-router/config.json << 'EOF'
119
119
  },
120
120
  {
121
121
  "name": "glm",
122
- "api_base_url": "https://api.z.ai/api/paas/v4/chat/completions",
122
+ "api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
123
123
  "api_key": "$GLM_API_KEY",
124
- "models": ["glm-4.6", "glm-4.5", "glm-4-plus"],
124
+ "models": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-4-plus"],
125
125
  "transformer": { "use": [] }
126
126
  },
127
127
  {
@@ -206,7 +206,7 @@ const INTENTS = {
206
206
  /[\u0600-\u06FF]/, // Arabic
207
207
  /[\u0400-\u04FF]/, // Cyrillic
208
208
  ],
209
- route: "glm,glm-4.6"
209
+ route: "glm,glm-4.7"
210
210
  },
211
211
  HEAVY_REASONING: {
212
212
  patterns: [
@@ -314,4 +314,4 @@ source ~/.zshrc && ccr code
314
314
  | Qwen | https://dashscope.console.aliyun.com/apiKey | Alibaba |
315
315
  | GLM | https://open.bigmodel.cn/usercenter/apikeys | Zhipu AI |
316
316
  | OpenRouter | https://openrouter.ai/keys | Multiple |
317
- | GitHub Copilot | https://github.com/settings/tokens | `copilot` scope |
317
+ | GitHub Copilot | https://github.com/settings/tokens | `copilot` scope |
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@halilertekin/claude-code-router-config",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "Multi-provider configuration for Claude Code Router with intent-based routing, advanced CLI tools, analytics, and smart routing. Setup OpenAI, Anthropic, Gemini, Qwen, GLM, OpenRouter, and GitHub Copilot with intelligent routing.",
5
5
  "main": "install.js",
6
6
  "bin": {
7
7
  "ccr-setup": "install.js",
8
+ "ccr-glm-setup": "bin/ccr-glm-setup",
8
9
  "ccr": "cli/commands.js",
9
10
  "ccr-benchmark": "cli/benchmark.js",
10
11
  "ccr-analytics": "cli/analytics.js",
@@ -21,6 +22,7 @@
21
22
  "health": "node logging/health-monitor.js"
22
23
  },
23
24
  "files": [
25
+ "bin/",
24
26
  "config/",
25
27
  "cli/",
26
28
  "logging/",
@@ -28,6 +30,7 @@
28
30
  "plugins/",
29
31
  "web-dashboard/",
30
32
  "install.sh",
33
+ "setup-glm.sh",
31
34
  "install.js",
32
35
  "postinstall.js",
33
36
  ".env.example",
File without changes
package/setup-glm.sh ADDED
@@ -0,0 +1,245 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ CONFIG_DIR="$HOME/.claude-code-router"
6
+ BIN_DIR="$HOME/.local/bin"
7
+ KEYS_FILE="$CONFIG_DIR/keys.env"
8
+ ZSHRC="${HOME}/.zshrc"
9
+
10
+ GLM_KEY="${GLM_API_KEY:-}"
11
+ SKIP_INSTALL=0
12
+ NONINTERACTIVE=0
13
+
14
+ usage() {
15
+ cat <<'USAGE'
16
+ Usage: ./setup-glm.sh [--key <GLM_API_KEY>] [--skip-install] [--non-interactive]
17
+
18
+ Installs/updates CCR (if missing), writes GLM-only config,
19
+ creates ~/.claude-code-router/keys.env, and installs a single
20
+ command: glm (plus aliases ccc and claude-glm).
21
+
22
+ Options:
23
+ --key <GLM_API_KEY> Provide GLM key non-interactively
24
+ --skip-install Do not install ccr if missing
25
+ --non-interactive Fail instead of prompting for key
26
+ USAGE
27
+ }
28
+
29
+ while [[ $# -gt 0 ]]; do
30
+ case "$1" in
31
+ --key)
32
+ GLM_KEY="${2:-}"
33
+ shift 2
34
+ ;;
35
+ --skip-install)
36
+ SKIP_INSTALL=1
37
+ shift
38
+ ;;
39
+ --non-interactive)
40
+ NONINTERACTIVE=1
41
+ shift
42
+ ;;
43
+ -h|--help)
44
+ usage
45
+ exit 0
46
+ ;;
47
+ *)
48
+ echo "Unknown option: $1" >&2
49
+ usage
50
+ exit 1
51
+ ;;
52
+ esac
53
+ done
54
+
55
+ ensure_ccr() {
56
+ if command -v ccr >/dev/null 2>&1; then
57
+ return 0
58
+ fi
59
+ if [[ "$SKIP_INSTALL" -eq 1 ]]; then
60
+ echo "ccr not found. Install it and rerun this script." >&2
61
+ exit 1
62
+ fi
63
+ if [[ "$(uname -s)" == "Darwin" ]] && command -v brew >/dev/null 2>&1; then
64
+ echo "Installing ccr via Homebrew..."
65
+ brew install halilertekin/tap/claude-code-router-config
66
+ return 0
67
+ fi
68
+ if command -v pnpm >/dev/null 2>&1; then
69
+ echo "Installing ccr via pnpm..."
70
+ pnpm add -g @halilertekin/claude-code-router-config
71
+ return 0
72
+ fi
73
+ if command -v npm >/dev/null 2>&1; then
74
+ echo "Installing ccr via npm..."
75
+ npm i -g @halilertekin/claude-code-router-config
76
+ return 0
77
+ fi
78
+ echo "Could not install ccr (brew/pnpm/npm missing)." >&2
79
+ exit 1
80
+ }
81
+
82
+ backup_file() {
83
+ local src="$1"
84
+ if [[ -f "$src" ]]; then
85
+ local ts
86
+ ts="$(date +"%Y%m%d%H%M%S")"
87
+ cp "$src" "${src}.${ts}.bak"
88
+ fi
89
+ }
90
+
91
+ write_keys() {
92
+ if [[ -z "${GLM_KEY}" ]]; then
93
+ if [[ "$NONINTERACTIVE" -eq 1 ]]; then
94
+ echo "GLM_API_KEY not provided. Use --key or set GLM_API_KEY env." >&2
95
+ exit 1
96
+ fi
97
+ read -r -s -p "Enter GLM_API_KEY: " GLM_KEY
98
+ echo ""
99
+ fi
100
+
101
+ mkdir -p "$CONFIG_DIR"
102
+ local tmp
103
+ tmp="$(mktemp)"
104
+ if [[ -f "$KEYS_FILE" ]]; then
105
+ grep -v '^GLM_API_KEY=' "$KEYS_FILE" | grep -v '^export GLM_API_KEY=' > "$tmp" || true
106
+ fi
107
+ echo "export GLM_API_KEY=\"${GLM_KEY}\"" >> "$tmp"
108
+ mv "$tmp" "$KEYS_FILE"
109
+ chmod 600 "$KEYS_FILE"
110
+ }
111
+
112
+ install_wrapper() {
113
+ mkdir -p "$BIN_DIR"
114
+ cat > "$BIN_DIR/ccr-glm" <<'EOS'
115
+ #!/usr/bin/env bash
116
+ set -euo pipefail
117
+
118
+ ROUTER_DIR="$HOME/.claude-code-router"
119
+ KEYS_FILE="$ROUTER_DIR/keys.env"
120
+
121
+ load_keys() {
122
+ if [[ -f "$KEYS_FILE" ]]; then
123
+ while IFS= read -r line || [[ -n "$line" ]]; do
124
+ line="${line%$'\r'}"
125
+ line="${line%%#*}"
126
+ line="$(echo "$line" | sed -E 's/^[[:space:]]*//; s/[[:space:]]*$//')"
127
+ [[ -z "$line" ]] && continue
128
+ if [[ "$line" =~ ^(export[[:space:]]+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then
129
+ key="${BASH_REMATCH[2]}"
130
+ val="${BASH_REMATCH[3]}"
131
+ val="$(echo "$val" | sed -E 's/^[[:space:]]*//; s/[[:space:]]*$//')"
132
+ if [[ ${#val} -ge 2 ]]; then
133
+ if [[ "${val:0:1}" == "\"" && "${val: -1}" == "\"" ]]; then
134
+ val="${val:1:-1}"
135
+ elif [[ "${val:0:1}" == "'" && "${val: -1}" == "'" ]]; then
136
+ val="${val:1:-1}"
137
+ fi
138
+ fi
139
+ val="${val%$'\r'}"
140
+ if [[ -n "$val" ]]; then
141
+ export "$key=$val"
142
+ fi
143
+ fi
144
+ done < "$KEYS_FILE"
145
+ fi
146
+ }
147
+
148
+ port_open() {
149
+ if command -v nc >/dev/null 2>&1; then
150
+ nc -z 127.0.0.1 3456 >/dev/null 2>&1
151
+ return $?
152
+ fi
153
+ python3 - <<'PY' >/dev/null 2>&1
154
+ import socket
155
+ s=socket.socket()
156
+ try:
157
+ s.connect(("127.0.0.1", 3456))
158
+ s.close()
159
+ raise SystemExit(0)
160
+ except Exception:
161
+ raise SystemExit(1)
162
+ PY
163
+ }
164
+
165
+ load_keys
166
+
167
+ if [[ -z "${GLM_API_KEY:-}" ]]; then
168
+ echo "GLM_API_KEY not set. Add it to ~/.claude-code-router/keys.env" >&2
169
+ exit 1
170
+ fi
171
+
172
+ if ! port_open; then
173
+ if ! command -v ccr >/dev/null 2>&1; then
174
+ echo "ccr not found in PATH." >&2
175
+ exit 1
176
+ fi
177
+ (ccr start >/dev/null 2>&1 & disown) || true
178
+ for _ in {1..20}; do
179
+ if port_open; then
180
+ break
181
+ fi
182
+ sleep 0.5
183
+ done
184
+ fi
185
+
186
+ if ! port_open; then
187
+ echo "CCR failed to start (port 3456 not listening)." >&2
188
+ exit 1
189
+ fi
190
+
191
+ eval "$(ccr activate)"
192
+
193
+ export ANTHROPIC_MODEL="glm,glm-4.7"
194
+ export ANTHROPIC_DEFAULT_SONNET_MODEL="glm,glm-4.7"
195
+ export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm,glm-4.7"
196
+ export ANTHROPIC_DEFAULT_OPUS_MODEL="glm,glm-4.7"
197
+ export CLAUDE_CODE_SUBAGENT_MODEL="glm,glm-4.7"
198
+ export ANTHROPIC_SMALL_FAST_MODEL="glm,glm-4.7"
199
+
200
+ CLAUDE_BIN="$HOME/.claude/local/claude"
201
+ if [[ ! -x "$CLAUDE_BIN" ]]; then
202
+ CLAUDE_BIN="$(command -v claude || true)"
203
+ fi
204
+ if [[ -z "${CLAUDE_BIN:-}" ]]; then
205
+ echo "claude binary not found. Install Claude Code first." >&2
206
+ exit 1
207
+ fi
208
+
209
+ "$CLAUDE_BIN" "$@"
210
+ EOS
211
+ chmod +x "$BIN_DIR/ccr-glm"
212
+ ln -sf "$BIN_DIR/ccr-glm" "$BIN_DIR/glm"
213
+ ln -sf "$BIN_DIR/ccr-glm" "$BIN_DIR/ccc"
214
+ ln -sf "$BIN_DIR/ccr-glm" "$BIN_DIR/claude-glm"
215
+ }
216
+
217
+ ensure_path() {
218
+ if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
219
+ if [[ ! -f "$ZSHRC" ]]; then
220
+ touch "$ZSHRC"
221
+ fi
222
+ if ! grep -q "CCR GLM PATH" "$ZSHRC" 2>/dev/null; then
223
+ cat >> "$ZSHRC" <<'EOF'
224
+ # >>> CCR GLM PATH >>>
225
+ export PATH="$HOME/.local/bin:$PATH"
226
+ # <<< CCR GLM PATH <<<
227
+ EOF
228
+ fi
229
+ fi
230
+ }
231
+
232
+ ensure_ccr
233
+ mkdir -p "$CONFIG_DIR"
234
+ backup_file "$CONFIG_DIR/config.json"
235
+ backup_file "$CONFIG_DIR/intent-router.js"
236
+ cp "$SCRIPT_DIR/config/glm-only.json" "$CONFIG_DIR/config.json"
237
+ cp "$SCRIPT_DIR/config/intent-router-glm.js" "$CONFIG_DIR/intent-router.js"
238
+ write_keys
239
+ install_wrapper
240
+ ensure_path
241
+
242
+ echo ""
243
+ echo "GLM setup complete."
244
+ echo "Run: source ~/.zshrc"
245
+ echo "Then: glm"
@@ -55,9 +55,9 @@
55
55
  },
56
56
  {
57
57
  "name": "glm",
58
- "api_base_url": "https://api.z.ai/api/paas/v4/chat/completions",
58
+ "api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
59
59
  "api_key": "$GLM_API_KEY",
60
- "models": ["glm-4.6", "glm-4.5"],
60
+ "models": ["glm-4.7", "glm-4.6", "glm-4.5"],
61
61
  "transformer": {
62
62
  "use": []
63
63
  },
@@ -108,4 +108,4 @@
108
108
  "Everyday tasks",
109
109
  "Balanced requirements"
110
110
  ]
111
- }
111
+ }
@@ -31,9 +31,9 @@
31
31
  },
32
32
  {
33
33
  "name": "glm",
34
- "api_base_url": "https://api.z.ai/api/paas/v4/chat/completions",
34
+ "api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
35
35
  "api_key": "$GLM_API_KEY",
36
- "models": ["glm-4.5", "glm-4.6"],
36
+ "models": ["glm-4.7", "glm-4.6", "glm-4.5"],
37
37
  "transformer": {
38
38
  "use": []
39
39
  },
@@ -93,4 +93,4 @@
93
93
  "expectedSavings": "70-90% compared to premium models",
94
94
  "costProfile": "Very Low",
95
95
  "qualityLevel": "Good for most tasks"
96
- }
96
+ }