@halilertekin/claude-code-router-config 1.3.6 → 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/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,75 +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.7 |
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
+ ## Installation (Full Router)
68
69
 
69
- ### One-shot GLM setup (Claude login + GLM API)
70
+ ### Option 1: PNPM (Recommended)
70
71
 
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
-
97
- ### Option 1: Homebrew (Recommended for macOS)
98
-
99
- > [!CAUTION]
100
- > **Conflict Warning**: Do NOT install using both Homebrew and PNPM/NPM simultaneously. Choose only ONE method to avoid command conflicts.
101
-
102
- The easiest way to install and keep updated on macOS.
103
-
104
- ```bash
105
- brew uninstall ccr # Remove old versions if present
106
- brew install halilertekin/tap/claude-code-router-config
107
- ```
108
-
109
- After installation, edit your API keys in `~/.env` and start the router:
110
- ```bash
111
- ccr code
112
- ```
113
-
114
- ### Option 2: PNPM (Alternative)
115
-
116
- Use this if you are on Linux or prefer using a Node package manager.
117
-
118
- > [!WARNING]
119
- > 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).
120
73
 
121
74
  ```bash
122
75
  pnpm add -g @halilertekin/claude-code-router-config
123
76
  # System is ready! Run: ccr --help
124
77
  ```
125
78
 
126
- ### Option 3: Manual Setup
79
+ ### Option 2: Manual Setup
127
80
 
128
81
  #### 1. Install Dependencies
129
82
 
@@ -148,23 +101,6 @@ cp .env.example ~/.env
148
101
  # Edit ~/.env with your API keys
149
102
  ```
150
103
 
151
- Or add to `~/.zshrc` / `~/.bashrc`:
152
-
153
- ```bash
154
- # Claude Code Router - API Keys
155
- export OPENAI_API_KEY="sk-..."
156
- export ANTHROPIC_API_KEY="sk-ant-..."
157
- export GEMINI_API_KEY="AIza..."
158
- export QWEN_API_KEY="sk-..."
159
- export GLM_API_KEY="..."
160
- export OPENROUTER_API_KEY="sk-or-..."
161
- export GITHUB_COPIOT_API_KEY="ghu_..."
162
-
163
- # Router Connection
164
- export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
165
- export NO_PROXY="127.0.0.1"
166
- ```
167
-
168
104
  #### 4. Start Router
169
105
 
170
106
  ```bash
@@ -172,80 +108,6 @@ source ~/.zshrc
172
108
  ccr code
173
109
  ```
174
110
 
175
- ## Usage
176
-
177
- ### 🔧 Advanced CLI Commands
178
-
179
- #### Testing & Benchmarking
180
- ```bash
181
- # Test provider connectivity
182
- ccr test openai gpt-4o
183
- ccr test anthropic claude-sonnet-4-latest
184
-
185
- # Benchmark all providers
186
- ccr benchmark --all --compare-speed
187
- ccr benchmark full 5 --provider=openai --provider=anthropic
188
-
189
- # Load testing
190
- ccr benchmark load openai gpt-4o --concurrent=5 --duration=30
191
- ```
192
-
193
- #### Configuration Management
194
- ```bash
195
- # Validate configuration
196
- ccr config validate
197
-
198
- # Backup configuration
199
- ccr config backup
200
-
201
- # Apply templates
202
- ccr config template performance-optimized
203
- ccr config template cost-optimized
204
- ccr config template quality-focused
205
- ccr config template development
206
- ccr config template balanced
207
-
208
- # Show detailed status with costs
209
- ccr status --detailed --show-costs
210
- ```
211
-
212
- #### Analytics & Monitoring
213
- ```bash
214
- # View today's analytics
215
- ccr analytics today --detailed
216
-
217
- # View period analytics
218
- ccr analytics week --detailed
219
- ccr analytics month --detailed
220
-
221
- # Export data
222
- ccr analytics export --format=csv --period=month
223
-
224
- # Health monitoring
225
- ccr health --all-providers
226
- ```
227
-
228
- ### Basic Commands
229
-
230
- ```bash
231
- ccr start # Start router
232
- ccr code # Start with Claude Code
233
- ccr stop # Stop router
234
- ```
235
-
236
- ### Switch Models (Runtime)
237
-
238
- Inside Claude Code:
239
-
240
- ```
241
- /model openai,gpt-4o
242
- /model anthropic,claude-sonnet-4-latest
243
- /model gemini,gemini-2.5-flash
244
- /model qwen,qwen-plus
245
- /model glm,glm-4.7
246
- /model copilot,copilot
247
- ```
248
-
249
111
  ## API Key Setup
250
112
 
251
113
  | Provider | Link | Notes |
@@ -254,22 +116,10 @@ Inside Claude Code:
254
116
  | Anthropic | https://console.anthropic.com/settings/keys | Claude models |
255
117
  | Gemini | https://aistudio.google.com/apikey | Google AI models |
256
118
  | Qwen | https://dashscope.console.aliyun.com/apiKey | Alibaba Cloud |
257
- | GLM | https://open.bigmodel.cn/usercenter/apikeys | Zhipu AI |
119
+ | GLM (z.ai) | https://open.bigmodel.cn/usercenter/apikeys | Zhipu AI / z.ai |
258
120
  | OpenRouter | https://openrouter.ai/keys | Multiple models |
259
121
  | GitHub Copilot | https://github.com/settings/tokens | `copilot` scope |
260
122
 
261
- ## Testing
262
-
263
- ```bash
264
- # Test different routing scenarios
265
- claude "Write a Python sorting function" # → OpenAI
266
- claude "Explain microservices architecture" # → Anthropic
267
- claude "Quick summary of REST APIs" # → Gemini
268
- claude "List files in current directory" # → Qwen
269
- claude "Translate to Chinese: Hello" # → GLM
270
- claude "Help me debug this React component" # → GitHub Copilot
271
- ```
272
-
273
123
  ## Configuration Templates
274
124
 
275
125
  | Template | Best For | Priority | Cost | Speed |
@@ -287,23 +137,6 @@ ccr config template cost-optimized # Cheapest
287
137
  ccr config template quality-focused # Best quality
288
138
  ```
289
139
 
290
- ## Smart Routing Features
291
-
292
- ### 🧠 Adaptive Intelligence
293
- - **Learning**: Improves routing based on historical performance
294
- - **Context Awareness**: Considers request complexity and timing
295
- - **Cost Awareness**: Respects budget constraints and optimization goals
296
-
297
- ### 🔄 Auto-Fallback
298
- - **Health Checks**: Monitors provider status every 30 seconds
299
- - **Circuit Breaker**: Automatically routes around failed providers
300
- - **Graceful Degradation**: Maintains service during provider issues
301
-
302
- ### 📈 Performance Optimization
303
- - **Latency Tracking**: Monitors and optimizes for speed
304
- - **Success Rate**: Reliability-based routing decisions
305
- - **Load Balancing**: Distributes requests optimally
306
-
307
140
  ## Analytics Dashboard
308
141
 
309
142
  View comprehensive analytics via:
@@ -330,22 +163,6 @@ Metrics tracked:
330
163
  - [Setup Prompt (TR)](docs/SETUP_PROMPT.md)
331
164
  - [Configuration Templates Guide](templates/README.md)
332
165
 
333
- ## What's New
334
-
335
- ### v1.1.0 Features
336
- - ✨ Advanced CLI tools for testing and benchmarking
337
- - 📊 Built-in analytics and cost tracking
338
- - 🧠 Smart routing with machine learning
339
- - 📋 Configuration templates for different use cases
340
- - 🔍 Health monitoring and auto-fallback
341
- - 📝 Enhanced logging with metrics
342
-
343
- ### Coming Soon
344
- - 🌐 Enhanced web dashboard
345
- - 🔌 Plugin system for custom providers
346
- - 🤖 AI-powered optimization recommendations
347
- - 📱 Mobile-friendly analytics dashboard
348
-
349
166
  ## Attribution
350
167
 
351
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.
@@ -362,4 +179,4 @@ MIT © [Halil Ertekin](https://github.com/halilertekin)
362
179
 
363
180
  ## 🌟 Show Your Support
364
181
 
365
- If you find this useful, please give it a ⭐ on [GitHub](https://github.com/halilertekin/CC-RouterMultiProvider)!
182
+ If you find this useful, please give it a ⭐ on [GitHub](https://github.com/halilertekin/CC-RouterMultiProvider)!
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,7 +38,7 @@
38
38
  },
39
39
  {
40
40
  "name": "glm",
41
- "api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
41
+ "api_base_url": "https://api.z.ai/api/anthropic",
42
42
  "api_key": "$GLM_API_KEY",
43
43
  "models": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-4-plus"],
44
44
  "transformer": { "use": [] }
@@ -10,7 +10,7 @@
10
10
  "Providers": [
11
11
  {
12
12
  "name": "glm",
13
- "api_base_url": "https://api.z.ai/api/coding/paas/v4/chat/completions",
13
+ "api_base_url": "https://api.z.ai/api/anthropic",
14
14
  "api_key": "$GLM_API_KEY",
15
15
  "models": [
16
16
  "glm-4.7",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halilertekin/claude-code-router-config",
3
- "version": "1.3.6",
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": {
File without changes