@halilertekin/claude-code-router-config 2.0.8 → 2.1.0
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/CHANGELOG.md +11 -0
- package/README.md +36 -2
- package/docs/PROVIDER_SETUP.md +599 -0
- package/package.json +1 -1
- package/setup-glm.sh +10 -0
- package/web-dashboard/public/index.html +1 -0
- package/web-dashboard/public/js/dashboard.js +66 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
- **NEW**: UI now supports 3 languages - Turkish (TR), Dutch (NL), and English (EN)
|
|
5
|
+
- **NEW**: Comprehensive provider setup guide added with multi-provider routing documentation
|
|
6
|
+
- **NEW**: Inter-provider routing with automatic fallback support
|
|
7
|
+
- **IMPROVED**: Default routing strategy now prioritizes GLM (z.ai) for cost optimization
|
|
8
|
+
- **IMPROVED**: Smart intent router updated with GLM-first approach for all intents
|
|
9
|
+
- **DOCS**: Added `docs/PROVIDER_SETUP.md` with detailed multi-language instructions
|
|
10
|
+
|
|
11
|
+
## 2.0.9
|
|
12
|
+
- GLM print mode disables attachments to avoid EMFILE (too many open files) watcher errors.
|
|
13
|
+
|
|
3
14
|
## 2.0.8
|
|
4
15
|
- GLM setup now installs direct z.ai `glm` wrapper by default and keeps `glm-ccr` for router usage.
|
|
5
16
|
- Safer `.env` loading in `ccc` (ignores comments/invalid lines) and updated setup docs.
|
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# Claude Code Router Config - Advanced Multi-Provider Setup
|
|
2
2
|
|
|
3
|
-
🚀 **v2.0.
|
|
3
|
+
🚀 **v2.0.9** - Unified router + config package 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 in v2.0.
|
|
7
|
+
## ✨ New in v2.0.9
|
|
8
|
+
- `glm`/`glm-ccr` print mode disables attachments to avoid EMFILE (too many open files) watcher errors.
|
|
9
|
+
|
|
10
|
+
Includes all v2.0.8 improvements:
|
|
8
11
|
- UI üzerinden `.env` anahtarları ekleme/güncelleme (TR/NL).
|
|
9
12
|
- `~/.env` otomatik yükleme ile API anahtarlarının bulunması (CLI + health monitor).
|
|
10
13
|
- **z.ai Support**: Native integration for GLM-4.7 via z.ai (PPInfra).
|
|
@@ -173,12 +176,43 @@ Metrics tracked:
|
|
|
173
176
|
|
|
174
177
|
## Documentation
|
|
175
178
|
|
|
179
|
+
- [**Provider Setup Guide** (EN/TR)](docs/PROVIDER_SETUP.md) - **Multiple providers with intelligent routing**
|
|
176
180
|
- [Complete Documentation (EN)](docs/FULL_DOCUMENTATION_EN.md)
|
|
177
181
|
- [Complete Documentation (TR)](docs/FULL_DOCUMENTATION.md)
|
|
178
182
|
- [Setup Prompt (EN)](docs/SETUP_PROMPT_EN.md)
|
|
179
183
|
- [Setup Prompt (TR)](docs/SETUP_PROMPT.md)
|
|
180
184
|
- [Configuration Templates Guide](templates/README.md)
|
|
181
185
|
|
|
186
|
+
## Provider Setup / Sağlayıcı Kurulumu 🆕
|
|
187
|
+
|
|
188
|
+
**📖 Read the [Provider Setup Guide](docs/PROVIDER_SETUP.md) for:**
|
|
189
|
+
- How to add multiple providers (OpenRouter, OpenAI, Gemini, Qwen)
|
|
190
|
+
- Inter-provider routing with automatic fallback
|
|
191
|
+
- Cost optimization strategies (up to 87% savings!)
|
|
192
|
+
- Configuration examples and troubleshooting
|
|
193
|
+
|
|
194
|
+
**🔗 Hızlı Provider Ekleme:**
|
|
195
|
+
|
|
196
|
+
| Provider | Get API Key | Cost (1M tokens) |
|
|
197
|
+
|----------|-------------|------------------|
|
|
198
|
+
| [GLM (z.ai)](https://open.bigmodel.cn/) | [Sign Up](https://open.bigmodel.cn/) | ~$0.50 ⭐ |
|
|
199
|
+
| [Qwen](https://dashscope-intl.aliyuncs.com/) | [Sign Up](https://dashscope-intl.aliyuncs.com/) | ~$0.10 |
|
|
200
|
+
| [Gemini](https://ai.google.dev/) | [Sign Up](https://ai.google.dev/) | ~$0.01 |
|
|
201
|
+
| [OpenAI](https://platform.openai.com/) | [Sign Up](https://platform.openai.com/) | ~$2.50 |
|
|
202
|
+
| [OpenRouter](https://openrouter.ai/) | [Sign Up](https://openrouter.ai/) | Variable |
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Add to ~/.env
|
|
206
|
+
export GLM_API_KEY="your_key_here"
|
|
207
|
+
export OPENROUTER_API_KEY="your_key_here"
|
|
208
|
+
export GEMINI_API_KEY="your_key_here"
|
|
209
|
+
|
|
210
|
+
# Verify setup
|
|
211
|
+
ccr status --detailed
|
|
212
|
+
ccr test glm
|
|
213
|
+
ccr benchmark --all
|
|
214
|
+
```
|
|
215
|
+
|
|
182
216
|
## License
|
|
183
217
|
|
|
184
218
|
MIT © [Halil Ertekin](https://github.com/halilertekin)
|
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
# Provider Setup Guide / Provider Kurulum Rehberi
|
|
2
|
+
|
|
3
|
+
[English](#english) | [Türkçe](#türkçe)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<a name="english"></a>
|
|
8
|
+
## English | Provider Setup Guide
|
|
9
|
+
|
|
10
|
+
### Overview
|
|
11
|
+
|
|
12
|
+
Claude Code Router supports multiple AI providers with intelligent routing. You can use one or more providers simultaneously, and the router will automatically switch between them based on cost, performance, and quality.
|
|
13
|
+
|
|
14
|
+
### Current Architecture
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
Request → Smart Intent Router → Provider Selection → AI Response
|
|
18
|
+
↓ ↓
|
|
19
|
+
Intent Analysis GLM (Primary)
|
|
20
|
+
(Cost Optimized) Qwen (Fallback)
|
|
21
|
+
Gemini (Backup)
|
|
22
|
+
OpenAI (Premium)
|
|
23
|
+
Anthropic (Quality)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Quick Start
|
|
27
|
+
|
|
28
|
+
1. **Install & Setup**
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g @halilertekin/claude-code-router-config
|
|
31
|
+
ccr-setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. **Configure API Keys**
|
|
35
|
+
```bash
|
|
36
|
+
# Edit your .env file
|
|
37
|
+
nano ~/.env
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. **Start Router**
|
|
41
|
+
```bash
|
|
42
|
+
ccr start # Start router server
|
|
43
|
+
ccr code # Start router + Claude Code
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### Available Providers
|
|
49
|
+
|
|
50
|
+
| Provider | API Base URL | Cost (per 1M tokens) | Best For |
|
|
51
|
+
|----------|-------------|---------------------|----------|
|
|
52
|
+
| **GLM (z.ai)** | `https://api.z.ai/api/anthropic` | ~$0.50 | Cost-effective, multilingual |
|
|
53
|
+
| **Qwen** | `https://dashscope-intl.aliyuncs.com/...` | ~$0.10 | Coding, cost-optimized |
|
|
54
|
+
| **Gemini** | `https://generativelanguage.googleapis.com/...` | ~$0.01 | Fast responses |
|
|
55
|
+
| **OpenAI** | `https://api.openai.com/v1/...` | ~$2.50 | Premium quality |
|
|
56
|
+
| **Anthropic** | `https://api.anthropic.com/v1/...` | ~$3.00 | Best quality |
|
|
57
|
+
| **OpenRouter** | `https://openrouter.ai/api/v1/...` | Variable | Variety, fallback |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### Adding Providers
|
|
62
|
+
|
|
63
|
+
#### Step 1: Get API Key
|
|
64
|
+
|
|
65
|
+
**GLM (z.ai)**
|
|
66
|
+
- Website: https://open.bigmodel.cn/
|
|
67
|
+
- Pricing: https://open.bigmodel.cn/pricing
|
|
68
|
+
- Sign up → Create API Key
|
|
69
|
+
|
|
70
|
+
**Qwen (Alibaba)**
|
|
71
|
+
- Website: https://dashscope-intl.aliyuncs.com/
|
|
72
|
+
- Pricing: https://dashscope-intl.aliyuncs.com/pricing
|
|
73
|
+
- Sign up → Create API Key
|
|
74
|
+
|
|
75
|
+
**Gemini (Google)**
|
|
76
|
+
- Website: https://ai.google.dev/
|
|
77
|
+
- Pricing: Free tier available
|
|
78
|
+
- Sign up → Create API Key
|
|
79
|
+
|
|
80
|
+
**OpenAI**
|
|
81
|
+
- Website: https://platform.openai.com/
|
|
82
|
+
- Pricing: https://openai.com/pricing
|
|
83
|
+
- Sign up → Create API Key
|
|
84
|
+
|
|
85
|
+
**Anthropic**
|
|
86
|
+
- Website: https://console.anthropic.com/
|
|
87
|
+
- Pricing: https://anthropic.com/pricing
|
|
88
|
+
- Sign up → Create API Key
|
|
89
|
+
|
|
90
|
+
**OpenRouter**
|
|
91
|
+
- Website: https://openrouter.ai/
|
|
92
|
+
- Pricing: Varies by model
|
|
93
|
+
- Sign up → Create API Key
|
|
94
|
+
|
|
95
|
+
#### Step 2: Add to `.env` File
|
|
96
|
+
|
|
97
|
+
Edit `~/.env`:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Primary Provider (GLM - Recommended)
|
|
101
|
+
export GLM_API_KEY="your_glm_api_key_here"
|
|
102
|
+
|
|
103
|
+
# Additional Providers (Optional - for routing)
|
|
104
|
+
export QWEN_API_KEY="your_qwen_api_key_here"
|
|
105
|
+
export GEMINI_API_KEY="your_gemini_api_key_here"
|
|
106
|
+
export OPENAI_API_KEY="your_openai_api_key_here"
|
|
107
|
+
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
|
|
108
|
+
export OPENROUTER_API_KEY="your_openrouter_api_key_here"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Step 3: Verify Setup
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Check configuration
|
|
115
|
+
ccr status --detailed
|
|
116
|
+
|
|
117
|
+
# Test provider connection
|
|
118
|
+
ccr test glm
|
|
119
|
+
ccr test qwen
|
|
120
|
+
ccr test gemini
|
|
121
|
+
|
|
122
|
+
# Benchmark providers
|
|
123
|
+
ccr benchmark --all --compare-speed
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### Inter-Provider Routing
|
|
129
|
+
|
|
130
|
+
The router automatically switches between providers based on:
|
|
131
|
+
|
|
132
|
+
1. **Intent Analysis**
|
|
133
|
+
- Coding tasks → GLM (cost-effective)
|
|
134
|
+
- Reasoning → GLM with fallback to Qwen
|
|
135
|
+
- Fast responses → GLM or Gemini
|
|
136
|
+
- Complex tasks → OpenAI with fallback
|
|
137
|
+
|
|
138
|
+
2. **Cost Optimization**
|
|
139
|
+
- Primary: GLM (~$0.50/1M tokens)
|
|
140
|
+
- Fallback 1: Qwen (~$0.10/1M tokens)
|
|
141
|
+
- Fallback 2: Gemini (~$0.01/1M tokens)
|
|
142
|
+
- Premium: OpenAI/Anthropic (when quality needed)
|
|
143
|
+
|
|
144
|
+
3. **Health Monitoring**
|
|
145
|
+
- If provider fails → automatic fallback
|
|
146
|
+
- Performance tracking → optimal provider selection
|
|
147
|
+
- Cost tracking → budget management
|
|
148
|
+
|
|
149
|
+
#### Routing Flow Example
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
User Request: "Help me refactor this code"
|
|
153
|
+
↓
|
|
154
|
+
Intent Router: CODING intent detected
|
|
155
|
+
↓
|
|
156
|
+
Provider Selection: glm,glm-4.7 (primary)
|
|
157
|
+
↓
|
|
158
|
+
Try GLM → Success ✅
|
|
159
|
+
OR
|
|
160
|
+
Try GLM → Failure ❌ → Fallback to Qwen ✅
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### Configuration Examples
|
|
166
|
+
|
|
167
|
+
#### Example 1: Cost-Optimized Setup (GLM Only)
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"Router": {
|
|
172
|
+
"default": "glm,glm-4.7",
|
|
173
|
+
"fallbacks": ["qwen,qwen-plus", "gemini,gemini-2.5-flash"]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
`.env`:
|
|
179
|
+
```bash
|
|
180
|
+
export GLM_API_KEY="your_key"
|
|
181
|
+
# No other keys needed - GLM handles everything
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Example 2: Multi-Provider Setup (With Routing)
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"Router": {
|
|
189
|
+
"default": "glm,glm-4.7",
|
|
190
|
+
"fallbacks": ["qwen,qwen-plus", "gemini,gemini-2.5-flash", "openai,gpt-4o"]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`.env`:
|
|
196
|
+
```bash
|
|
197
|
+
export GLM_API_KEY="your_glm_key"
|
|
198
|
+
export QWEN_API_KEY="your_qwen_key"
|
|
199
|
+
export GEMINI_API_KEY="your_gemini_key"
|
|
200
|
+
export OPENAI_API_KEY="your_openai_key"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Example 3: Quality-Optimized Setup (Premium)
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"Router": {
|
|
208
|
+
"default": "anthropic,claude-sonnet-4-latest",
|
|
209
|
+
"fallbacks": ["openai,gpt-4o", "glm,glm-4.7"]
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
`.env`:
|
|
215
|
+
```bash
|
|
216
|
+
export ANTHROPIC_API_KEY="your_anthropic_key"
|
|
217
|
+
export OPENAI_API_KEY="your_openai_key"
|
|
218
|
+
export GLM_API_KEY="your_glm_key"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
### Advanced: Custom Routing Rules
|
|
224
|
+
|
|
225
|
+
Edit `~/.claude-code-router/smart-intent-router.js`:
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
// Custom routing based on your needs
|
|
229
|
+
CODING: {
|
|
230
|
+
patterns: [/\b(coding|debug|refactor)\b/i],
|
|
231
|
+
route: "glm,glm-4.7", // Primary
|
|
232
|
+
fallbacks: [
|
|
233
|
+
"qwen,qwen3-coder-plus", // Fallback 1
|
|
234
|
+
"openai,gpt-4o" // Fallback 2 (premium)
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
### Troubleshooting
|
|
242
|
+
|
|
243
|
+
**Issue: Provider not working**
|
|
244
|
+
```bash
|
|
245
|
+
# Check if API key is set
|
|
246
|
+
echo $GLM_API_KEY
|
|
247
|
+
|
|
248
|
+
# Test connection
|
|
249
|
+
ccr test glm
|
|
250
|
+
|
|
251
|
+
# Check logs
|
|
252
|
+
tail -f ~/.claude-code-router/logs/app.log
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Issue: Always using same provider**
|
|
256
|
+
```bash
|
|
257
|
+
# Check router config
|
|
258
|
+
cat ~/.claude-code-router/config.json | jq '.Router'
|
|
259
|
+
|
|
260
|
+
# Verify intent router
|
|
261
|
+
cat ~/.claude-code-router/smart-intent-router.js
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Issue: High costs**
|
|
265
|
+
```bash
|
|
266
|
+
# Check analytics
|
|
267
|
+
ccr analytics --today
|
|
268
|
+
|
|
269
|
+
# Verify cost optimization is enabled
|
|
270
|
+
ccr status --detailed --show-costs
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### Cost Comparison
|
|
276
|
+
|
|
277
|
+
| Task | Claude Sonnet 4.5 | GLM 4.7 | Savings |
|
|
278
|
+
|------|-------------------|---------|---------|
|
|
279
|
+
| 100K coding tasks | $300 | $50 | **83%** |
|
|
280
|
+
| 1M tokens input | $3.00 | $0.50 | **83%** |
|
|
281
|
+
| 1M tokens output | $15.00 | $2.00 | **87%** |
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
<a name="türkçe"></a>
|
|
286
|
+
---
|
|
287
|
+
## Türkçe | Provider Kurulum Rehberi
|
|
288
|
+
|
|
289
|
+
### Genel Bakış
|
|
290
|
+
|
|
291
|
+
Claude Code Router, birden fazla AI sağlayıcısını akıllı yönlendirme ile destekler. Aynı anda bir veya daha fazla sağlayıcı kullanabilirsiniz, router maliyet, performans ve kaliteye göre otomatik olarak sağlayıcılar arası geçiş yapar.
|
|
292
|
+
|
|
293
|
+
### Mevcut Mimari
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
İstek → Akıllı Intent Router → Sağlayıcı Seçimi → AI Cevabı
|
|
297
|
+
↓ ↓
|
|
298
|
+
Intent Analizi GLM (Birincil)
|
|
299
|
+
(Maliyet Optimize) Qwen (Yedek)
|
|
300
|
+
Gemini (Yedek 2)
|
|
301
|
+
OpenAI (Premium)
|
|
302
|
+
Anthropic (Kalite)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Hızlı Başlangıç
|
|
306
|
+
|
|
307
|
+
1. **Kurulum**
|
|
308
|
+
```bash
|
|
309
|
+
npm install -g @halilertekin/claude-code-router-config
|
|
310
|
+
ccr-setup
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
2. **API Key Yapılandırma**
|
|
314
|
+
```bash
|
|
315
|
+
# .env dosyasını düzenle
|
|
316
|
+
nano ~/.env
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
3. **Router'ı Başlat**
|
|
320
|
+
```bash
|
|
321
|
+
ccr start # Router sunucusunu başlat
|
|
322
|
+
ccr code # Router + Claude Code'u başlat
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
### Mevcut Sağlayıcılar
|
|
328
|
+
|
|
329
|
+
| Sağlayıcı | API URL | Maliyet (1M token) | En İyi Kullanım |
|
|
330
|
+
|-----------|---------|-------------------|-----------------|
|
|
331
|
+
| **GLM (z.ai)** | `https://api.z.ai/api/anthropic` | ~$0.50 | Ucuz, çok dilli |
|
|
332
|
+
| **Qwen** | `https://dashscope-intl.aliyuncs.com/...` | ~$0.10 | Kodlama, ucuz |
|
|
333
|
+
| **Gemini** | `https://generativelanguage.googleapis.com/...` | ~$0.01 | Hızlı cevap |
|
|
334
|
+
| **OpenAI** | `https://api.openai.com/v1/...` | ~$2.50 | Premium kalite |
|
|
335
|
+
| **Anthropic** | `https://api.anthropic.com/v1/...` | ~$3.00 | En iyi kalite |
|
|
336
|
+
| **OpenRouter** | `https://openrouter.ai/api/v1/...` | Değişken | Çeşitlilik |
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
### Sağlayıcı Ekleme
|
|
341
|
+
|
|
342
|
+
#### Adım 1: API Key Al
|
|
343
|
+
|
|
344
|
+
**GLM (z.ai)**
|
|
345
|
+
- Website: https://open.bigmodel.cn/
|
|
346
|
+
- Fiyatlandırma: https://open.bigmodel.cn/pricing
|
|
347
|
+
- Kayıt ol → API Key Oluştur
|
|
348
|
+
|
|
349
|
+
**Qwen (Alibaba)**
|
|
350
|
+
- Website: https://dashscope-intl.aliyuncs.com/
|
|
351
|
+
- Fiyatlandırma: https://dashscope-intl.aliyuncs.com/pricing
|
|
352
|
+
- Kayıt ol → API Key Oluştur
|
|
353
|
+
|
|
354
|
+
**Gemini (Google)**
|
|
355
|
+
- Website: https://ai.google.dev/
|
|
356
|
+
- Fiyatlandırma: Ücretsiz tier mevcut
|
|
357
|
+
- Kayıt ol → API Key Oluştur
|
|
358
|
+
|
|
359
|
+
**OpenAI**
|
|
360
|
+
- Website: https://platform.openai.com/
|
|
361
|
+
- Fiyatlandırma: https://openai.com/pricing
|
|
362
|
+
- Kayıt ol → API Key Oluştur
|
|
363
|
+
|
|
364
|
+
**Anthropic**
|
|
365
|
+
- Website: https://console.anthropic.com/
|
|
366
|
+
- Fiyatlandırma: https://anthropic.com/pricing
|
|
367
|
+
- Kayıt ol → API Key Oluştur
|
|
368
|
+
|
|
369
|
+
**OpenRouter**
|
|
370
|
+
- Website: https://openrouter.ai/
|
|
371
|
+
- Fiyatlandırma: Modele göre değişir
|
|
372
|
+
- Kayıt ol → API Key Oluştur
|
|
373
|
+
|
|
374
|
+
#### Adım 2: `.env` Dosyasına Ekle
|
|
375
|
+
|
|
376
|
+
`~/.env` dosyasını düzenle:
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Birincil Sağlayıcı (GLM - Önerilen)
|
|
380
|
+
export GLM_API_KEY="glm_api_key_buraya"
|
|
381
|
+
|
|
382
|
+
# Ek Sağlayıcılar (Opsiyonel - yönlendirme için)
|
|
383
|
+
export QWEN_API_KEY="qwen_api_key_buraya"
|
|
384
|
+
export GEMINI_API_KEY="gemini_api_key_buraya"
|
|
385
|
+
export OPENAI_API_KEY="openai_api_key_buraya"
|
|
386
|
+
export ANTHROPIC_API_KEY="anthropic_api_key_buraya"
|
|
387
|
+
export OPENROUTER_API_KEY="openrouter_api_key_buraya"
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
#### Adım 3: Kurulumu Doğrula
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
# Yapılandırmayı kontrol et
|
|
394
|
+
ccr status --detailed
|
|
395
|
+
|
|
396
|
+
# Sağlayıcı bağlantısını test et
|
|
397
|
+
ccr test glm
|
|
398
|
+
ccr test qwen
|
|
399
|
+
ccr test gemini
|
|
400
|
+
|
|
401
|
+
# Sağlayıcıları benchmark et
|
|
402
|
+
ccr benchmark --all --compare-speed
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
### Sağlayıcılar Arası Yönlendirme
|
|
408
|
+
|
|
409
|
+
Router, sağlayıcılar arasında şunlara göre otomatik geçiş yapar:
|
|
410
|
+
|
|
411
|
+
1. **Intent Analizi**
|
|
412
|
+
- Kodlama görevleri → GLM (ucuz)
|
|
413
|
+
- Akıl yürütme → GLM, Qwen yedeği
|
|
414
|
+
- Hızlı cevaplar → GLM veya Gemini
|
|
415
|
+
- Karmaşık görevler → OpenAI, yedeği mevcut
|
|
416
|
+
|
|
417
|
+
2. **Maliyet Optimizasyonu**
|
|
418
|
+
- Birincil: GLM (~$0.50/1M token)
|
|
419
|
+
- Yedek 1: Qwen (~$0.10/1M token)
|
|
420
|
+
- Yedek 2: Gemini (~$0.01/1M token)
|
|
421
|
+
- Premium: OpenAI/Anthropic (kalite gerektiğinde)
|
|
422
|
+
|
|
423
|
+
3. **Sağlık İzleme**
|
|
424
|
+
- Sağlayıcı başarısız → otomatik yedek
|
|
425
|
+
- Performans izleme → optimal sağlayıcı seçimi
|
|
426
|
+
- Maliyet izleme → bütçe yönetimi
|
|
427
|
+
|
|
428
|
+
#### Yönlendirme Akışı Örneği
|
|
429
|
+
|
|
430
|
+
```
|
|
431
|
+
Kullanıcı İsteği: "Bu kodu refactor etmemeye yardımcı olur musun?"
|
|
432
|
+
↓
|
|
433
|
+
Intent Router: KODlama intent'i algılandı
|
|
434
|
+
↓
|
|
435
|
+
Sağlayıcı Seçimi: glm,glm-4.7 (birincil)
|
|
436
|
+
↓
|
|
437
|
+
GLM Dene → Başarılı ✅
|
|
438
|
+
VEYA
|
|
439
|
+
GLM Dene → Başarısız ❌ → Qwen Yedeği ✅
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
### Yapılandırma Örnekleri
|
|
445
|
+
|
|
446
|
+
#### Örnek 1: Maliyet Optimize Kurulum (Sadece GLM)
|
|
447
|
+
|
|
448
|
+
```json
|
|
449
|
+
{
|
|
450
|
+
"Router": {
|
|
451
|
+
"default": "glm,glm-4.7",
|
|
452
|
+
"fallbacks": ["qwen,qwen-plus", "gemini,gemini-2.5-flash"]
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
`.env`:
|
|
458
|
+
```bash
|
|
459
|
+
export GLM_API_KEY="senin_key"
|
|
460
|
+
# Diğer key'lere gerek yok - GLM her şeyi halleder
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
#### Örnek 2: Çoklu Sağlayıcı Kurulum (Yönlendirme ile)
|
|
464
|
+
|
|
465
|
+
```json
|
|
466
|
+
{
|
|
467
|
+
"Router": {
|
|
468
|
+
"default": "glm,glm-4.7",
|
|
469
|
+
"fallbacks": ["qwen,qwen-plus", "gemini,gemini-2.5-flash", "openai,gpt-4o"]
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
`.env`:
|
|
475
|
+
```bash
|
|
476
|
+
export GLM_API_KEY="glm_key"
|
|
477
|
+
export QWEN_API_KEY="qwen_key"
|
|
478
|
+
export GEMINI_API_KEY="gemini_key"
|
|
479
|
+
export OPENAI_API_KEY="openai_key"
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
#### Örnek 3: Kalite Optimize Kurulum (Premium)
|
|
483
|
+
|
|
484
|
+
```json
|
|
485
|
+
{
|
|
486
|
+
"Router": {
|
|
487
|
+
"default": "anthropic,claude-sonnet-4-latest",
|
|
488
|
+
"fallbacks": ["openai,gpt-4o", "glm,glm-4.7"]
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
`.env`:
|
|
494
|
+
```bash
|
|
495
|
+
export ANTHROPIC_API_KEY="anthropic_key"
|
|
496
|
+
export OPENAI_API_KEY="openai_key"
|
|
497
|
+
export GLM_API_KEY="glm_key"
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
### İleri Seviye: Özel Yönlendirme Kuralları
|
|
503
|
+
|
|
504
|
+
`~/.claude-code-router/smart-intent-router.js` dosyasını düzenle:
|
|
505
|
+
|
|
506
|
+
```javascript
|
|
507
|
+
// İhtiyaçlarına göre özel yönlendirme
|
|
508
|
+
CODING: {
|
|
509
|
+
patterns: [/\b(coding|debug|refactor|kodlama)\b/i],
|
|
510
|
+
route: "glm,glm-4.7", // Birincil
|
|
511
|
+
fallbacks: [
|
|
512
|
+
"qwen,qwen3-coder-plus", // Yedek 1
|
|
513
|
+
"openai,gpt-4o" // Yedek 2 (premium)
|
|
514
|
+
]
|
|
515
|
+
}
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
### Sorun Giderme
|
|
521
|
+
|
|
522
|
+
**Sorun: Sağlayıcı çalışmıyor**
|
|
523
|
+
```bash
|
|
524
|
+
# API key'in ayarlanmış olduğunu kontrol et
|
|
525
|
+
echo $GLM_API_KEY
|
|
526
|
+
|
|
527
|
+
# Bağlantıyı test et
|
|
528
|
+
ccr test glm
|
|
529
|
+
|
|
530
|
+
# Logları kontrol et
|
|
531
|
+
tail -f ~/.claude-code-router/logs/app.log
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
**Sorun: Her zaman aynı sağlayıcıyı kullanıyor**
|
|
535
|
+
```bash
|
|
536
|
+
# Router yapılandırmasını kontrol et
|
|
537
|
+
cat ~/.claude-code-router/config.json | jq '.Router'
|
|
538
|
+
|
|
539
|
+
# Intent router'ı doğrula
|
|
540
|
+
cat ~/.claude-code-router/smart-intent-router.js
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
**Sorun: Yüksek maliyetler**
|
|
544
|
+
```bash
|
|
545
|
+
# Analitikleri kontrol et
|
|
546
|
+
ccr analytics --today
|
|
547
|
+
|
|
548
|
+
# Maliyet optimizasyonunun açık olduğunu doğrula
|
|
549
|
+
ccr status --detailed --show-costs
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
### Maliyet Karşılaştırması
|
|
555
|
+
|
|
556
|
+
| Görev | Claude Sonnet 4.5 | GLM 4.7 | Tasarruf |
|
|
557
|
+
|------|-------------------|---------|---------|
|
|
558
|
+
| 100K kodlama görevi | $300 | $50 | **%83** |
|
|
559
|
+
| 1M token input | $3.00 | $0.50 | **%83** |
|
|
560
|
+
| 1M token output | $15.00 | $2.00 | **%87** |
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
### CLI Komutları
|
|
565
|
+
|
|
566
|
+
```bash
|
|
567
|
+
# Router yönetimi
|
|
568
|
+
ccr start # Router'ı başlat
|
|
569
|
+
ccr stop # Router'ı durdur
|
|
570
|
+
ccr restart # Router'ı yeniden başlat
|
|
571
|
+
ccr status # Durumu göster
|
|
572
|
+
ccr code # Router + Claude Code
|
|
573
|
+
|
|
574
|
+
# İstatistikler
|
|
575
|
+
ccr analytics --today # Bugünün kullanımı
|
|
576
|
+
ccr analytics # Haftalık özet
|
|
577
|
+
ccr benchmark # Karşılaştırmalı test
|
|
578
|
+
|
|
579
|
+
# Test ve doğrulama
|
|
580
|
+
ccr test glm # GLM bağlantısını test et
|
|
581
|
+
ccr config validate # Yapılandırmayı doğrula
|
|
582
|
+
|
|
583
|
+
# Dashboard
|
|
584
|
+
ccr ui # Web dashboard'ı aç
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
### Daha Fazla Bilgi
|
|
590
|
+
|
|
591
|
+
- **GitHub Repository**: https://github.com/halilertekin/CC-RouterMultiProvider
|
|
592
|
+
- **Issues**: https://github.com/halilertekin/CC-RouterMultiProvider/issues
|
|
593
|
+
- **Changelog**: [CHANGELOG.md](../CHANGELOG.md)
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
*Created by Halil Ertekin*
|
|
598
|
+
*Version: 2.0.9*
|
|
599
|
+
*Last Updated: 2025-01-11*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halilertekin/claude-code-router-config",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
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": {
|
package/setup-glm.sh
CHANGED
|
@@ -210,6 +210,11 @@ export ANTHROPIC_DEFAULT_HAIKU_MODEL="${ANTHROPIC_DEFAULT_HAIKU_MODEL:-glm,glm-4
|
|
|
210
210
|
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-glm,glm-4.5-air}"
|
|
211
211
|
export CLAUDE_CODE_SUBAGENT_MODEL="${CLAUDE_CODE_SUBAGENT_MODEL:-glm,glm-4.7}"
|
|
212
212
|
|
|
213
|
+
# Avoid file watcher exhaustion in non-interactive mode.
|
|
214
|
+
if [[ " $* " == *" -p "* || " $* " == *" --print "* ]]; then
|
|
215
|
+
export CLAUDE_CODE_DISABLE_ATTACHMENTS=1
|
|
216
|
+
fi
|
|
217
|
+
|
|
213
218
|
CLAUDE_BIN="$HOME/.claude/local/claude"
|
|
214
219
|
if [[ ! -x "$CLAUDE_BIN" ]]; then
|
|
215
220
|
CLAUDE_BIN="$(command -v claude || true)"
|
|
@@ -275,6 +280,11 @@ export ANTHROPIC_DEFAULT_HAIKU_MODEL="${ANTHROPIC_DEFAULT_HAIKU_MODEL:-glm-4.5-a
|
|
|
275
280
|
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-glm-4.5-air}"
|
|
276
281
|
export CLAUDE_CODE_SUBAGENT_MODEL="${CLAUDE_CODE_SUBAGENT_MODEL:-glm-4.7}"
|
|
277
282
|
|
|
283
|
+
# Avoid file watcher exhaustion in non-interactive mode.
|
|
284
|
+
if [[ " $* " == *" -p "* || " $* " == *" --print "* ]]; then
|
|
285
|
+
export CLAUDE_CODE_DISABLE_ATTACHMENTS=1
|
|
286
|
+
fi
|
|
287
|
+
|
|
278
288
|
CLAUDE_BIN="$HOME/.claude/local/claude"
|
|
279
289
|
if [[ ! -x "$CLAUDE_BIN" ]]; then
|
|
280
290
|
CLAUDE_BIN="$(command -v claude || true)"
|
|
@@ -130,6 +130,65 @@ class Dashboard {
|
|
|
130
130
|
statusDown: 'Niet beschikbaar',
|
|
131
131
|
statusUnknown: 'Onbekend',
|
|
132
132
|
dataUnavailable: 'Geen gegevens'
|
|
133
|
+
},
|
|
134
|
+
en: {
|
|
135
|
+
appTitle: 'Claude Code Router',
|
|
136
|
+
appSubtitle: 'Unified router dashboard',
|
|
137
|
+
refresh: 'Refresh',
|
|
138
|
+
connected: 'Connected',
|
|
139
|
+
disconnected: 'Disconnected',
|
|
140
|
+
overview: 'Overview',
|
|
141
|
+
lastUpdated: 'Last updated',
|
|
142
|
+
requests: 'Requests',
|
|
143
|
+
tokens: 'Tokens',
|
|
144
|
+
cost: 'Cost',
|
|
145
|
+
avgLatency: 'Avg Latency',
|
|
146
|
+
providers: 'Providers',
|
|
147
|
+
quickActions: 'Quick Actions',
|
|
148
|
+
export: 'Export',
|
|
149
|
+
refreshHealth: 'Refresh Health',
|
|
150
|
+
analytics: 'Analytics',
|
|
151
|
+
periodLabel: 'Period',
|
|
152
|
+
periodToday: 'Today',
|
|
153
|
+
periodWeek: 'Last 7 days',
|
|
154
|
+
periodMonth: 'Last 30 days',
|
|
155
|
+
totalRequests: 'Total Requests',
|
|
156
|
+
totalTokens: 'Total Tokens',
|
|
157
|
+
totalCost: 'Total Cost',
|
|
158
|
+
topProviders: 'Most Used',
|
|
159
|
+
health: 'Health',
|
|
160
|
+
system: 'System',
|
|
161
|
+
uptime: 'Uptime',
|
|
162
|
+
memory: 'Memory',
|
|
163
|
+
cpu: 'CPU',
|
|
164
|
+
node: 'Node Version',
|
|
165
|
+
config: 'Configuration',
|
|
166
|
+
configSummary: 'Summary',
|
|
167
|
+
providerCount: 'Provider count',
|
|
168
|
+
defaultRoute: 'Default route',
|
|
169
|
+
logging: 'Logging',
|
|
170
|
+
configJson: 'Configuration',
|
|
171
|
+
env: 'Environment Variables',
|
|
172
|
+
envHint: 'Quickly update keys',
|
|
173
|
+
envStatus: 'Status',
|
|
174
|
+
envUpdate: 'Update',
|
|
175
|
+
envKeyLabel: 'Key',
|
|
176
|
+
envKeyPlaceholder: 'CUSTOM_KEY',
|
|
177
|
+
envValueLabel: 'Value',
|
|
178
|
+
envSave: 'Save',
|
|
179
|
+
envSaved: 'Saved',
|
|
180
|
+
envSaveError: 'Save failed',
|
|
181
|
+
envSet: 'Set',
|
|
182
|
+
envMissing: 'Missing',
|
|
183
|
+
envPath: 'File',
|
|
184
|
+
envSelect: 'Select key',
|
|
185
|
+
logOn: 'On',
|
|
186
|
+
logOff: 'Off',
|
|
187
|
+
statusHealthy: 'Healthy',
|
|
188
|
+
statusDegraded: 'Degraded',
|
|
189
|
+
statusDown: 'Down',
|
|
190
|
+
statusUnknown: 'Unknown',
|
|
191
|
+
dataUnavailable: 'No data'
|
|
133
192
|
}
|
|
134
193
|
};
|
|
135
194
|
}
|
|
@@ -137,10 +196,10 @@ class Dashboard {
|
|
|
137
196
|
detectLanguage() {
|
|
138
197
|
const stored = localStorage.getItem('ccr_lang');
|
|
139
198
|
if (stored) return stored;
|
|
140
|
-
const lang = navigator.language || '
|
|
199
|
+
const lang = navigator.language || 'en';
|
|
141
200
|
if (lang.startsWith('nl')) return 'nl';
|
|
142
201
|
if (lang.startsWith('tr')) return 'tr';
|
|
143
|
-
return '
|
|
202
|
+
return 'en';
|
|
144
203
|
}
|
|
145
204
|
|
|
146
205
|
t(key) {
|
|
@@ -512,7 +571,11 @@ class Dashboard {
|
|
|
512
571
|
}
|
|
513
572
|
|
|
514
573
|
locale() {
|
|
515
|
-
|
|
574
|
+
switch (this.lang) {
|
|
575
|
+
case 'nl': return 'nl-NL';
|
|
576
|
+
case 'tr': return 'tr-TR';
|
|
577
|
+
default: return 'en-US';
|
|
578
|
+
}
|
|
516
579
|
}
|
|
517
580
|
|
|
518
581
|
formatNumber(value) {
|