|
1 | 1 | # Claude Code Router Config - Advanced Multi-Provider Setup |
2 | 2 |
|
3 | | -🚀 **v2.2.0** - GLM-5 Support with Coding Plan & API Credit endpoints! |
| 3 | +🚀 **v2.3.0** - Multi-provider Claude Code routing with GLM-5, Claude Pro, DeepSeek & more! |
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.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: |
11 | | -- UI üzerinden `.env` anahtarları ekleme/güncelleme (TR/NL). |
12 | | -- `~/.env` otomatik yükleme ile API anahtarlarının bulunması (CLI + health monitor). |
13 | | -- **z.ai Support**: Native integration for GLM-4.7 via z.ai (PPInfra). |
14 | | -- **Lightweight Mode**: New `ccc` function for zero-dependency routing. |
15 | | -- **Direct GLM Alias**: `glm` now launches GLM-4.7 directly via z.ai; `glm-ccr` keeps router mode. |
16 | | -- **Non-interactive install**: CI-friendly installer flags and env controls. |
17 | | -- **Unified router**: Built-in router service, no external dependency required. |
18 | | -- **UI refresh**: Daha sade ve responsive tasarım, TR/NL dil desteği. |
19 | | - |
20 | | -## 🚀 Setup on Another Machine (Fastest Way) |
21 | | - |
22 | | -If you just want to use the `ccc` command (Claude Code Commander) and `glm` alias without installing the full Node.js router stack: |
23 | | - |
24 | | -1. **Clone the repo:** |
25 | | - ```bash |
26 | | - mkdir -p ~/code |
27 | | - git clone git@github.com:halilertekin/CC-RouterMultiProvider.git ~/code/claude-code-router-config |
28 | | - ``` |
29 | | - |
30 | | -2. **Source the script in your `.zshrc`:** |
31 | | - Add this line to your `~/.zshrc`: |
32 | | - ```bash |
33 | | - [[ -f "$HOME/code/claude-code-router-config/cli/ccc.zsh" ]] && source "$HOME/code/claude-code-router-config/cli/ccc.zsh" |
34 | | - ``` |
35 | | - |
36 | | -3. **Configure Keys:** |
37 | | - Create `~/.env` or `~/.ccm_config` with your keys: |
38 | | - ```bash |
39 | | - export GLM_API_KEY="your_zai_key_here" |
40 | | - export DEEPSEEK_API_KEY="your_deepseek_key_here" |
41 | | - ``` |
42 | | - |
43 | | -4. **Reload & Run:** |
44 | | - ```bash |
45 | | - source ~/.zshrc |
46 | | - glm # Launches GLM-5 via z.ai Coding Plan |
47 | | - glmapi # Launches GLM-5 via z.ai API Credits |
48 | | - ccc ds # Launches DeepSeek |
49 | | - ccc claude # Launches Official Claude (Pro) |
50 | | - ``` |
| 7 | +## ✨ Quick Start |
51 | 8 |
|
52 | | ---- |
| 9 | +```bash |
| 10 | +# 1. Install |
| 11 | +npm install -g @halilertekin/claude-code-router-config |
| 12 | + |
| 13 | +# 2. Configure API keys in ~/.env |
| 14 | +export GLM_API_KEY="your_key" |
53 | 15 |
|
54 | | -## Features |
| 16 | +# 3. Use with Claude Code |
| 17 | +glm # → z.ai GLM-5 (Coding Plan) |
| 18 | +glmapi # → z.ai GLM-5 (API Credits) |
| 19 | +claude-pro # → Anthropic Claude Pro |
| 20 | +deepseek # → DeepSeek |
| 21 | +``` |
55 | 22 |
|
56 | | -- **Node.js 16+ Support**: Compatible with modern Node.js environments |
57 | | -- **7 Provider Support**: OpenAI, Anthropic, Gemini, Qwen, GLM, OpenRouter, GitHub Copilot |
58 | | -- **Smart Intent-Based Routing**: Automatically selects the best model based on your request |
59 | | -- **Advanced CLI Tools**: Test, benchmark, analyze, and monitor your setup |
60 | | -- **Analytics & Cost Tracking**: Detailed insights into usage and spending |
61 | | -- **Configuration Templates**: Pre-optimized setups for different use cases |
62 | | -- **Health Monitoring**: Real-time provider status and automatic failover |
63 | | -- **Enhanced Logging**: Detailed logs with metrics and performance data |
| 23 | +--- |
64 | 24 |
|
65 | | -## Routing Strategy |
| 25 | +## 📋 Available Aliases |
66 | 26 |
|
67 | | -| Request Type | Provider | Model | |
68 | | -|--------------|----------|-------| |
69 | | -| Code writing, debugging | OpenAI | gpt-4o | |
70 | | -| Deep analysis, architecture | Anthropic | claude-sonnet-4 | |
71 | | -| Quick responses, summaries | Gemini | gemini-2.5-flash | |
72 | | -| Simple tasks | Qwen | qwen-plus | |
73 | | -| Translation, multilingual | GLM | glm-4.7 (z.ai) | |
74 | | -| Complex algorithms | OpenAI | o1 | |
75 | | -| Coding assistance | GitHub Copilot | copilot | |
| 27 | +| Alias | Provider | Endpoint | Model | Best For | |
| 28 | +|-------|----------|----------|-------|----------| |
| 29 | +| `glm` | z.ai | Coding Plan | GLM-5 | Subscription coding | |
| 30 | +| `glmapi` | z.ai | API Credits | GLM-5 | Pay-per-use | |
| 31 | +| `claude-pro` | Anthropic | Official | Claude Sonnet 4.5 | Premium coding | |
| 32 | +| `deepseek` | DeepSeek | Anthropic API | deepseek-chat | Budget coding | |
| 33 | +| `minimax` / `mm` | MiniMax | Anthropic API | M2.5 | Long context | |
76 | 34 |
|
77 | | -## Installation (Full Router) |
| 35 | +--- |
78 | 36 |
|
79 | | -### Option 1: PNPM (Recommended) |
| 37 | +## 🚀 Installation |
80 | 38 |
|
81 | | -Use this if you want the full routing capabilities (benchmarking, analytics, etc). |
| 39 | +### Option 1: NPM (Recommended) |
82 | 40 |
|
83 | 41 | ```bash |
84 | | -pnpm add -g @halilertekin/claude-code-router-config |
85 | | -# System is ready! Run: ccr --help |
| 42 | +npm install -g @halilertekin/claude-code-router-config |
| 43 | +source ~/.zshrc |
86 | 44 | ``` |
87 | 45 |
|
88 | | -Then run the installer to copy config files: |
| 46 | +### Option 2: Manual |
89 | 47 |
|
90 | 48 | ```bash |
91 | | -ccr-setup |
| 49 | +git clone git@github.com:halilertekin/CC-RouterMultiProvider.git ~/code/claude-code-router-config |
92 | 50 | ``` |
93 | 51 |
|
94 | | -Non-interactive usage (CI): |
95 | | - |
| 52 | +Then add to `~/.zshrc`: |
96 | 53 | ```bash |
97 | | -CCR_CONFIG_NO_PROMPT=1 ccr-setup |
98 | | -CCR_CONFIG_OVERWRITE=1 ccr-setup |
99 | | -# or |
100 | | -ccr-setup --overwrite |
| 54 | +[[ -f "$HOME/code/claude-code-router-config/cli/ccc.zsh" ]] && source "$HOME/code/claude-code-router-config/cli/ccc.zsh" |
101 | 55 | ``` |
102 | 56 |
|
103 | | -### Option 2: Manual Setup |
| 57 | +--- |
104 | 58 |
|
105 | | -#### 1. Copy Configuration Files |
| 59 | +## 🔑 API Key Setup |
| 60 | + |
| 61 | +Add to `~/.env`: |
106 | 62 |
|
107 | 63 | ```bash |
108 | | -mkdir -p ~/.claude-code-router |
109 | | -cp config/config.json ~/.claude-code-router/ |
110 | | -cp config/intent-router.js ~/.claude-code-router/ |
111 | | -cp config/smart-intent-router.js ~/.claude-code-router/ |
| 64 | +# z.ai (GLM) - https://z.ai/apikeys |
| 65 | +export GLM_API_KEY="your_zai_key" |
| 66 | + |
| 67 | +# Anthropic Claude Pro - https://console.anthropic.com/settings/keys |
| 68 | +export ANTHROPIC_API_KEY="your_anthropic_key" |
| 69 | + |
| 70 | +# DeepSeek - https://platform.deepseek.com/ |
| 71 | +export DEEPSEEK_API_KEY="your_deepseek_key" |
| 72 | + |
| 73 | +# MiniMax - https://platform.minimax.io/ |
| 74 | +export MINIMAX_API_KEY="your_minimax_key" |
| 75 | + |
| 76 | +# OpenAI - https://platform.openai.com/api-keys |
| 77 | +export OPENAI_API_KEY="your_openai_key" |
| 78 | + |
| 79 | +# Gemini - https://aistudio.google.com/apikey |
| 80 | +export GEMINI_API_KEY="your_gemini_key" |
112 | 81 | ``` |
113 | 82 |
|
114 | | -#### 2. Set Up Environment Variables |
| 83 | +--- |
| 84 | + |
| 85 | +## 💻 Claude Code Usage |
115 | 86 |
|
116 | | -Create `.env` file: |
| 87 | +### Direct Aliases |
117 | 88 |
|
118 | 89 | ```bash |
119 | | -cp .env.example ~/.env |
120 | | -# Edit ~/.env with your API keys |
| 90 | +# GLM via Coding Plan (subscription) |
| 91 | +glm |
| 92 | + |
| 93 | +# GLM via API Credits (pay-per-use) |
| 94 | +glmapi |
| 95 | + |
| 96 | +# Official Claude Pro |
| 97 | +claude-pro |
| 98 | + |
| 99 | +# DeepSeek |
| 100 | +deepseek |
121 | 101 | ``` |
122 | 102 |
|
123 | | -#### 3. Start Router |
| 103 | +### With Arguments |
124 | 104 |
|
125 | 105 | ```bash |
126 | | -source ~/.zshrc |
127 | | -node router/server.js |
| 106 | +glm "write a React component" |
| 107 | +glmapi --print "explain this code" |
| 108 | +claude-pro --dangerous-skip-install |
128 | 109 | ``` |
129 | 110 |
|
130 | | -## API Key Setup |
| 111 | +--- |
131 | 112 |
|
132 | | -| Provider | Link | Notes | |
133 | | -|----------|------|-------| |
134 | | -| OpenAI | https://platform.openai.com/api-keys | gpt-4o, o1 models | |
135 | | -| Anthropic | https://console.anthropic.com/settings/keys | Claude models | |
136 | | -| Gemini | https://aistudio.google.com/apikey | Google AI models | |
137 | | -| Qwen | https://dashscope.console.aliyun.com/apiKey | Alibaba Cloud | |
138 | | -| GLM (z.ai) | https://open.bigmodel.cn/usercenter/apikeys | Zhipu AI / z.ai | |
139 | | -| OpenRouter | https://openrouter.ai/keys | Multiple models | |
140 | | -| GitHub Copilot | https://github.com/settings/tokens | `copilot` scope | |
| 113 | +## 🏢 Provider Details |
141 | 114 |
|
142 | | -## Configuration Templates |
| 115 | +### z.ai (GLM) |
143 | 116 |
|
144 | | -| Template | Best For | Priority | Cost | Speed | |
145 | | -|----------|----------|----------|------|-------| |
146 | | -| **performance-optimized** | Real-time apps, chatbots | Speed | Low | ⭐⭐⭐⭐⭐ | |
147 | | -| **cost-optimized** | Budget-conscious, bulk processing | Cost | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | |
148 | | -| **quality-focused** | Critical tasks, research | Quality | High | ⭐⭐ | |
149 | | -| **development** | Coding, debugging | Coding | Medium | ⭐⭐⭐⭐ | |
150 | | -| **balanced** | General use | Balanced | Medium | ⭐⭐⭐⭐ | |
| 117 | +- **Website**: https://z.ai |
| 118 | +- **Models**: GLM-5, GLM-4.7, GLM-4.5 |
| 119 | +- **Endpoints**: |
| 120 | + - Coding Plan: `https://api.z.ai/api/coding/paas/v4` |
| 121 | + - API Credits: `https://api.z.ai/api/paas/v4` |
| 122 | +- **Pricing**: Very competitive, 3x usage with Coding Plan |
| 123 | + |
| 124 | +### Claude Pro |
| 125 | + |
| 126 | +- **Website**: https://www.anthropic.com/claude |
| 127 | +- **Models**: Claude Sonnet 4.5, Claude Opus 4.5, Claude Haiku |
| 128 | +- **Access**: Use `claude login` or API key |
| 129 | + |
| 130 | +### DeepSeek |
| 131 | + |
| 132 | +- **Website**: https://www.deepseek.com |
| 133 | +- **Models**: deepseek-chat, deepseek-coder |
| 134 | +- **Pricing**: Very affordable |
| 135 | + |
| 136 | +### MiniMax |
| 137 | + |
| 138 | +- **Website**: https://www.minimax.io |
| 139 | +- **Models**: M2.5, M2, M1 |
| 140 | +- **Endpoint**: `https://api.minimax.io/anthropic` |
| 141 | +- **Features**: Ultra-long context (200k+ tokens), very competitive pricing |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## 🛠️ Advanced Features |
| 146 | + |
| 147 | +### Full Router Mode |
| 148 | + |
| 149 | +For intent-based routing with automatic model selection: |
151 | 150 |
|
152 | 151 | ```bash |
153 | | -# Quick template selection |
154 | | -ccr config template performance-optimized # Fastest |
155 | | -ccr config template cost-optimized # Cheapest |
156 | | -ccr config template quality-focused # Best quality |
| 152 | +ccr start # Start router |
| 153 | +ccr code # Start Claude Code with router |
| 154 | +ccr status # Check status |
| 155 | +ccr benchmark # Benchmark providers |
157 | 156 | ``` |
158 | 157 |
|
159 | | -## Analytics Dashboard |
| 158 | +### Configuration Templates |
160 | 159 |
|
161 | | -View comprehensive analytics via: |
162 | 160 | ```bash |
163 | | -# Web Dashboard (if enabled) |
164 | | -ccr ui |
| 161 | +ccr config template performance-optimized # Fastest |
| 162 | +ccr config template cost-optimized # Cheapest |
| 163 | +ccr config template quality-focused # Best quality |
| 164 | +``` |
165 | 165 |
|
166 | | -# CLI Analytics |
| 166 | +### Analytics |
| 167 | + |
| 168 | +```bash |
167 | 169 | ccr analytics today --detailed |
| 170 | +ccr ui # Web dashboard |
168 | 171 | ``` |
169 | 172 |
|
170 | | -Metrics tracked: |
171 | | -- Request volume and patterns |
172 | | -- Cost per provider/model |
173 | | -- Response times and latency |
174 | | -- Success/error rates |
175 | | -- Provider health status |
| 173 | +--- |
176 | 174 |
|
177 | | -## Documentation |
| 175 | +## 📖 Documentation |
178 | 176 |
|
179 | | -- [**Provider Setup Guide** (EN/TR)](docs/PROVIDER_SETUP.md) - **Multiple providers with intelligent routing** |
180 | | -- [Complete Documentation (EN)](docs/FULL_DOCUMENTATION_EN.md) |
181 | | -- [Complete Documentation (TR)](docs/FULL_DOCUMENTATION.md) |
182 | | -- [Setup Prompt (EN)](docs/SETUP_PROMPT_EN.md) |
183 | | -- [Setup Prompt (TR)](docs/SETUP_PROMPT.md) |
184 | | -- [Configuration Templates Guide](templates/README.md) |
| 177 | +- [Setup Guide (TR/EN)](SETUP.md) |
| 178 | +- [Provider Setup Guide](docs/PROVIDER_SETUP.md) |
| 179 | +- [Full Documentation](docs/FULL_DOCUMENTATION_EN.md) |
185 | 180 |
|
186 | | -## Provider Setup / Sağlayıcı Kurulumu 🆕 |
| 181 | +--- |
187 | 182 |
|
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 |
| 183 | +## 🔧 Troubleshooting |
193 | 184 |
|
194 | | -**🔗 Hızlı Provider Ekleme:** |
| 185 | +### "GLM_API_KEY not set" |
| 186 | +- Check `~/.env` file exists and has the key |
| 187 | +- Run `source ~/.zshrc` or restart terminal |
195 | 188 |
|
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 | |
| 189 | +### Model not working |
| 190 | +- Verify API key is valid |
| 191 | +- Check quotas/balance |
203 | 192 |
|
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 | | -``` |
| 193 | +--- |
215 | 194 |
|
216 | 195 | ## License |
217 | 196 |
|
218 | 197 | MIT © [Halil Ertekin](https://github.com/halilertekin) |
219 | 198 |
|
220 | 199 | --- |
221 | 200 |
|
222 | | -## 🌟 Show Your Support |
| 201 | +## ⭐ Support |
223 | 202 |
|
224 | 203 | If you find this useful, please give it a ⭐ on [GitHub](https://github.com/halilertekin/CC-RouterMultiProvider)! |
0 commit comments