@musistudio/claude-code-router 1.0.27 → 1.0.29
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 +132 -113
- package/README_zh.md +27 -7
- package/config.example.json +16 -8
- package/dist/cli.js +20752 -2467
- package/dist/index.html +223 -0
- package/package.json +6 -4
- package/scripts/build.js +35 -0
- package/ui/PROJECT.md +23 -0
- package/ui/README.md +69 -0
- package/ui/components.json +21 -0
- package/ui/config.example.json +177 -0
- package/ui/dist/index.html +223 -0
- package/ui/dist/vite.svg +1 -0
- package/ui/eslint.config.js +23 -0
- package/ui/index.html +13 -0
- package/ui/package-lock.json +5033 -0
- package/ui/package.json +53 -0
- package/ui/pnpm-lock.yaml +3459 -0
- package/ui/public/vite.svg +1 -0
- package/ui/tsconfig.app.json +26 -0
- package/ui/tsconfig.json +26 -0
- package/ui/tsconfig.tsbuildinfo +1 -0
- package/ui/vite.config.ts +16 -0
package/README.md
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
## ✨ Features
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
11
|
+
- **Model Routing**: Route requests to different models based on your needs (e.g., background tasks, thinking, long context).
|
|
12
|
+
- **Multi-Provider Support**: Supports various model providers like OpenRouter, DeepSeek, Ollama, Gemini, Volcengine, and SiliconFlow.
|
|
13
|
+
- **Request/Response Transformation**: Customize requests and responses for different providers using transformers.
|
|
14
|
+
- **Dynamic Model Switching**: Switch models on-the-fly within Claude Code using the `/model` command.
|
|
15
|
+
- **GitHub Actions Integration**: Trigger Claude Code tasks in your GitHub workflows.
|
|
16
|
+
- **Plugin System**: Extend functionality with custom transformers.
|
|
17
17
|
|
|
18
18
|
## 🚀 Getting Started
|
|
19
19
|
|
|
@@ -36,6 +36,7 @@ npm install -g @musistudio/claude-code-router
|
|
|
36
36
|
Create and configure your `~/.claude-code-router/config.json` file. For more details, you can refer to `config.example.json`.
|
|
37
37
|
|
|
38
38
|
The `config.json` file has several key sections:
|
|
39
|
+
|
|
39
40
|
- **`PROXY_URL`** (optional): You can set a proxy for API requests, for example: `"PROXY_URL": "http://127.0.0.1:7890"`.
|
|
40
41
|
- **`LOG`** (optional): You can enable logging by setting it to `true`. The log file will be located at `$HOME/.claude-code-router.log`.
|
|
41
42
|
- **`APIKEY`** (optional): You can set a secret key to authenticate requests. When set, clients must provide this key in the `Authorization` header (e.g., `Bearer your-secret-key`) or the `x-api-key` header. Example: `"APIKEY": "your-secret-key"`.
|
|
@@ -43,6 +44,7 @@ The `config.json` file has several key sections:
|
|
|
43
44
|
|
|
44
45
|
- **`Providers`**: Used to configure different model providers.
|
|
45
46
|
- **`Router`**: Used to set up routing rules. `default` specifies the default model, which will be used for all requests if no other route is configured.
|
|
47
|
+
- **`API_TIMEOUT_MS`**: Specifies the timeout for API calls in milliseconds.
|
|
46
48
|
|
|
47
49
|
Here is a comprehensive example:
|
|
48
50
|
|
|
@@ -51,6 +53,7 @@ Here is a comprehensive example:
|
|
|
51
53
|
"APIKEY": "your-secret-key",
|
|
52
54
|
"PROXY_URL": "http://127.0.0.1:7890",
|
|
53
55
|
"LOG": true,
|
|
56
|
+
"API_TIMEOUT_MS": 600000,
|
|
54
57
|
"Providers": [
|
|
55
58
|
{
|
|
56
59
|
"name": "openrouter",
|
|
@@ -106,16 +109,20 @@ Here is a comprehensive example:
|
|
|
106
109
|
"name": "modelscope",
|
|
107
110
|
"api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
|
|
108
111
|
"api_key": "",
|
|
109
|
-
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
|
|
112
|
+
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507"],
|
|
110
113
|
"transformer": {
|
|
111
114
|
"use": [
|
|
112
115
|
[
|
|
113
116
|
"maxtoken",
|
|
114
117
|
{
|
|
115
|
-
"max_tokens":
|
|
118
|
+
"max_tokens": 65536
|
|
116
119
|
}
|
|
117
|
-
]
|
|
118
|
-
|
|
120
|
+
],
|
|
121
|
+
"enhancetool"
|
|
122
|
+
],
|
|
123
|
+
"Qwen/Qwen3-235B-A22B-Thinking-2507": {
|
|
124
|
+
"use": ["reasoning"]
|
|
125
|
+
}
|
|
119
126
|
}
|
|
120
127
|
},
|
|
121
128
|
{
|
|
@@ -128,9 +135,10 @@ Here is a comprehensive example:
|
|
|
128
135
|
[
|
|
129
136
|
"maxtoken",
|
|
130
137
|
{
|
|
131
|
-
"max_tokens":
|
|
138
|
+
"max_tokens": 65536
|
|
132
139
|
}
|
|
133
|
-
]
|
|
140
|
+
],
|
|
141
|
+
"enhancetool"
|
|
134
142
|
]
|
|
135
143
|
}
|
|
136
144
|
}
|
|
@@ -140,12 +148,12 @@ Here is a comprehensive example:
|
|
|
140
148
|
"background": "ollama,qwen2.5-coder:latest",
|
|
141
149
|
"think": "deepseek,deepseek-reasoner",
|
|
142
150
|
"longContext": "openrouter,google/gemini-2.5-pro-preview",
|
|
151
|
+
"longContextThreshold": 60000,
|
|
143
152
|
"webSearch": "gemini,gemini-2.5-flash"
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
```
|
|
147
156
|
|
|
148
|
-
|
|
149
157
|
### 3. Running Claude Code with the Router
|
|
150
158
|
|
|
151
159
|
Start Claude Code using the router:
|
|
@@ -155,81 +163,93 @@ ccr code
|
|
|
155
163
|
```
|
|
156
164
|
|
|
157
165
|
> **Note**: After modifying the configuration file, you need to restart the service for the changes to take effect:
|
|
166
|
+
>
|
|
158
167
|
> ```shell
|
|
159
168
|
> ccr restart
|
|
160
169
|
> ```
|
|
161
170
|
|
|
171
|
+
### 4. UI Mode
|
|
172
|
+
|
|
173
|
+
For a more intuitive experience, you can use the UI mode to manage your configuration:
|
|
174
|
+
|
|
175
|
+
```shell
|
|
176
|
+
ccr ui
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
This will open a web-based interface where you can easily view and edit your `config.json` file.
|
|
180
|
+
|
|
162
181
|
#### Providers
|
|
163
182
|
|
|
164
183
|
The `Providers` array is where you define the different model providers you want to use. Each provider object requires:
|
|
165
184
|
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
170
|
-
-
|
|
185
|
+
- `name`: A unique name for the provider.
|
|
186
|
+
- `api_base_url`: The full API endpoint for chat completions.
|
|
187
|
+
- `api_key`: Your API key for the provider.
|
|
188
|
+
- `models`: A list of model names available from this provider.
|
|
189
|
+
- `transformer` (optional): Specifies transformers to process requests and responses.
|
|
171
190
|
|
|
172
191
|
#### Transformers
|
|
173
192
|
|
|
174
193
|
Transformers allow you to modify the request and response payloads to ensure compatibility with different provider APIs.
|
|
175
194
|
|
|
176
|
-
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
195
|
+
- **Global Transformer**: Apply a transformer to all models from a provider. In this example, the `openrouter` transformer is applied to all models under the `openrouter` provider.
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"name": "openrouter",
|
|
199
|
+
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
|
|
200
|
+
"api_key": "sk-xxx",
|
|
201
|
+
"models": [
|
|
202
|
+
"google/gemini-2.5-pro-preview",
|
|
203
|
+
"anthropic/claude-sonnet-4",
|
|
204
|
+
"anthropic/claude-3.5-sonnet"
|
|
205
|
+
],
|
|
206
|
+
"transformer": { "use": ["openrouter"] }
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
- **Model-Specific Transformer**: Apply a transformer to a specific model. In this example, the `deepseek` transformer is applied to all models, and an additional `tooluse` transformer is applied only to the `deepseek-chat` model.
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"name": "deepseek",
|
|
214
|
+
"api_base_url": "https://api.deepseek.com/chat/completions",
|
|
215
|
+
"api_key": "sk-xxx",
|
|
216
|
+
"models": ["deepseek-chat", "deepseek-reasoner"],
|
|
217
|
+
"transformer": {
|
|
218
|
+
"use": ["deepseek"],
|
|
219
|
+
"deepseek-chat": { "use": ["tooluse"] }
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
- **Passing Options to a Transformer**: Some transformers, like `maxtoken`, accept options. To pass options, use a nested array where the first element is the transformer name and the second is an options object.
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"name": "siliconflow",
|
|
228
|
+
"api_base_url": "https://api.siliconflow.cn/v1/chat/completions",
|
|
229
|
+
"api_key": "sk-xxx",
|
|
230
|
+
"models": ["moonshotai/Kimi-K2-Instruct"],
|
|
231
|
+
"transformer": {
|
|
232
|
+
"use": [
|
|
233
|
+
[
|
|
234
|
+
"maxtoken",
|
|
235
|
+
{
|
|
236
|
+
"max_tokens": 16384
|
|
237
|
+
}
|
|
219
238
|
]
|
|
220
|
-
|
|
239
|
+
]
|
|
221
240
|
}
|
|
222
|
-
|
|
241
|
+
}
|
|
242
|
+
```
|
|
223
243
|
|
|
224
244
|
**Available Built-in Transformers:**
|
|
225
245
|
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
246
|
+
- `deepseek`: Adapts requests/responses for DeepSeek API.
|
|
247
|
+
- `gemini`: Adapts requests/responses for Gemini API.
|
|
248
|
+
- `openrouter`: Adapts requests/responses for OpenRouter API.
|
|
249
|
+
- `groq`: Adapts requests/responses for groq API.
|
|
250
|
+
- `maxtoken`: Sets a specific `max_tokens` value.
|
|
251
|
+
- `tooluse`: Optimizes tool usage for certain models via `tool_choice`.
|
|
252
|
+
- `gemini-cli` (experimental): Unofficial support for Gemini via Gemini CLI [gemini-cli.js](https://gist.github.com/musistudio/1c13a65f35916a7ab690649d3df8d1cd).
|
|
233
253
|
|
|
234
254
|
**Custom Transformers:**
|
|
235
255
|
|
|
@@ -238,12 +258,12 @@ You can also create your own transformers and load them via the `transformers` f
|
|
|
238
258
|
```json
|
|
239
259
|
{
|
|
240
260
|
"transformers": [
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
261
|
+
{
|
|
262
|
+
"path": "$HOME/.claude-code-router/plugins/gemini-cli.js",
|
|
263
|
+
"options": {
|
|
264
|
+
"project": "xxx"
|
|
246
265
|
}
|
|
266
|
+
}
|
|
247
267
|
]
|
|
248
268
|
}
|
|
249
269
|
```
|
|
@@ -252,12 +272,12 @@ You can also create your own transformers and load them via the `transformers` f
|
|
|
252
272
|
|
|
253
273
|
The `Router` object defines which model to use for different scenarios:
|
|
254
274
|
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
-
|
|
258
|
-
-
|
|
259
|
-
-
|
|
260
|
-
|
|
275
|
+
- `default`: The default model for general tasks.
|
|
276
|
+
- `background`: A model for background tasks. This can be a smaller, local model to save costs.
|
|
277
|
+
- `think`: A model for reasoning-heavy tasks, like Plan Mode.
|
|
278
|
+
- `longContext`: A model for handling long contexts (e.g., > 60K tokens).
|
|
279
|
+
- `longContextThreshold` (optional): The token count threshold for triggering the long context model. Defaults to 60000 if not specified.
|
|
280
|
+
- `webSearch`: Used for handling web search tasks and this requires the model itself to support the feature. If you're using openrouter, you need to add the `:online` suffix after the model name.
|
|
261
281
|
|
|
262
282
|
You can also switch models dynamically in Claude Code with the `/model` command:
|
|
263
283
|
`/model provider_name,model_name`
|
|
@@ -290,11 +310,11 @@ Here is an example of a `custom-router.js` based on `custom-router.example.js`:
|
|
|
290
310
|
* @returns {Promise<string|null>} - A promise that resolves to the "provider,model_name" string, or null to use the default router.
|
|
291
311
|
*/
|
|
292
312
|
module.exports = async function router(req, config) {
|
|
293
|
-
const userMessage = req.body.messages.find(m => m.role ===
|
|
313
|
+
const userMessage = req.body.messages.find((m) => m.role === "user")?.content;
|
|
294
314
|
|
|
295
|
-
if (userMessage && userMessage.includes(
|
|
315
|
+
if (userMessage && userMessage.includes("explain this code")) {
|
|
296
316
|
// Use a powerful model for code explanation
|
|
297
|
-
return
|
|
317
|
+
return "openrouter,anthropic/claude-3.5-sonnet";
|
|
298
318
|
}
|
|
299
319
|
|
|
300
320
|
// Fallback to the default router configuration
|
|
@@ -302,7 +322,6 @@ module.exports = async function router(req, config) {
|
|
|
302
322
|
};
|
|
303
323
|
```
|
|
304
324
|
|
|
305
|
-
|
|
306
325
|
## 🤖 GitHub Actions
|
|
307
326
|
|
|
308
327
|
Integrate Claude Code Router into your CI/CD pipeline. After setting up [Claude Code Actions](https://docs.anthropic.com/en/docs/claude-code/github-actions), modify your `.github/workflows/claude.yaml` to use the router:
|
|
@@ -364,8 +383,8 @@ This setup allows for interesting automations, like running tasks during off-pea
|
|
|
364
383
|
|
|
365
384
|
## 📝 Further Reading
|
|
366
385
|
|
|
367
|
-
-
|
|
368
|
-
-
|
|
386
|
+
- [Project Motivation and How It Works](blog/en/project-motivation-and-how-it-works.md)
|
|
387
|
+
- [Maybe We Can Do More with the Router](blog/en/maybe-we-can-do-more-with-the-route.md)
|
|
369
388
|
|
|
370
389
|
## ❤️ Support & Sponsoring
|
|
371
390
|
|
|
@@ -387,39 +406,39 @@ A huge thank you to all our sponsors for their generous support!
|
|
|
387
406
|
- @Simon Leischnig
|
|
388
407
|
- [@duanshuaimin](https://github.com/duanshuaimin)
|
|
389
408
|
- [@vrgitadmin](https://github.com/vrgitadmin)
|
|
390
|
-
-
|
|
409
|
+
- @\*o
|
|
391
410
|
- [@ceilwoo](https://github.com/ceilwoo)
|
|
392
|
-
-
|
|
393
|
-
-
|
|
394
|
-
- @K
|
|
395
|
-
- @R
|
|
411
|
+
- @\*说
|
|
412
|
+
- @\*更
|
|
413
|
+
- @K\*g
|
|
414
|
+
- @R\*R
|
|
396
415
|
- [@bobleer](https://github.com/bobleer)
|
|
397
|
-
-
|
|
398
|
-
-
|
|
416
|
+
- @\*苗
|
|
417
|
+
- @\*划
|
|
399
418
|
- [@Clarence-pan](https://github.com/Clarence-pan)
|
|
400
419
|
- [@carter003](https://github.com/carter003)
|
|
401
|
-
- @S
|
|
402
|
-
-
|
|
403
|
-
-
|
|
404
|
-
- @Z
|
|
405
|
-
-
|
|
420
|
+
- @S\*r
|
|
421
|
+
- @\*晖
|
|
422
|
+
- @\*敏
|
|
423
|
+
- @Z\*z
|
|
424
|
+
- @\*然
|
|
406
425
|
- [@cluic](https://github.com/cluic)
|
|
407
|
-
-
|
|
426
|
+
- @\*苗
|
|
408
427
|
- [@PromptExpert](https://github.com/PromptExpert)
|
|
409
|
-
-
|
|
428
|
+
- @\*应
|
|
410
429
|
- [@yusnake](https://github.com/yusnake)
|
|
411
|
-
-
|
|
412
|
-
-
|
|
413
|
-
-
|
|
414
|
-
-
|
|
415
|
-
-
|
|
416
|
-
-
|
|
417
|
-
-
|
|
418
|
-
-
|
|
419
|
-
- @Z
|
|
420
|
-
-
|
|
430
|
+
- @\*飞
|
|
431
|
+
- @董\*
|
|
432
|
+
- @\*汀
|
|
433
|
+
- @\*涯
|
|
434
|
+
- @\*:-)
|
|
435
|
+
- @\*\*磊
|
|
436
|
+
- @\*琢
|
|
437
|
+
- @\*成
|
|
438
|
+
- @Z\*o
|
|
439
|
+
- @\*琨
|
|
421
440
|
- [@congzhangzh](https://github.com/congzhangzh)
|
|
422
|
-
-
|
|
423
|
-
|
|
441
|
+
- @\*\_
|
|
442
|
+
- @Z\*m
|
|
424
443
|
|
|
425
444
|
(If your name is masked, please contact me via my homepage email to update it with your GitHub username.)
|
package/README_zh.md
CHANGED
|
@@ -40,6 +40,7 @@ npm install -g @musistudio/claude-code-router
|
|
|
40
40
|
- **`HOST`** (可选): 您可以设置服务的主机地址。如果未设置 `APIKEY`,出于安全考虑,主机地址将强制设置为 `127.0.0.1`,以防止未经授权的访问。例如:`"HOST": "0.0.0.0"`。
|
|
41
41
|
- **`Providers`**: 用于配置不同的模型提供商。
|
|
42
42
|
- **`Router`**: 用于设置路由规则。`default` 指定默认模型,如果未配置其他路由,则该模型将用于所有请求。
|
|
43
|
+
- **`API_TIMEOUT_MS`**: API 请求超时时间,单位为毫秒。
|
|
43
44
|
|
|
44
45
|
这是一个综合示例:
|
|
45
46
|
|
|
@@ -48,6 +49,7 @@ npm install -g @musistudio/claude-code-router
|
|
|
48
49
|
"APIKEY": "your-secret-key",
|
|
49
50
|
"PROXY_URL": "http://127.0.0.1:7890",
|
|
50
51
|
"LOG": true,
|
|
52
|
+
"API_TIMEOUT_MS": 600000,
|
|
51
53
|
"Providers": [
|
|
52
54
|
{
|
|
53
55
|
"name": "openrouter",
|
|
@@ -103,16 +105,20 @@ npm install -g @musistudio/claude-code-router
|
|
|
103
105
|
"name": "modelscope",
|
|
104
106
|
"api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
|
|
105
107
|
"api_key": "",
|
|
106
|
-
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
|
|
108
|
+
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507"],
|
|
107
109
|
"transformer": {
|
|
108
110
|
"use": [
|
|
109
111
|
[
|
|
110
112
|
"maxtoken",
|
|
111
113
|
{
|
|
112
|
-
"max_tokens":
|
|
114
|
+
"max_tokens": 65536
|
|
113
115
|
}
|
|
114
|
-
]
|
|
115
|
-
|
|
116
|
+
],
|
|
117
|
+
"enhancetool"
|
|
118
|
+
],
|
|
119
|
+
"Qwen/Qwen3-235B-A22B-Thinking-2507": {
|
|
120
|
+
"use": ["reasoning"]
|
|
121
|
+
}
|
|
116
122
|
}
|
|
117
123
|
},
|
|
118
124
|
{
|
|
@@ -125,9 +131,10 @@ npm install -g @musistudio/claude-code-router
|
|
|
125
131
|
[
|
|
126
132
|
"maxtoken",
|
|
127
133
|
{
|
|
128
|
-
"max_tokens":
|
|
134
|
+
"max_tokens": 65536
|
|
129
135
|
}
|
|
130
|
-
]
|
|
136
|
+
],
|
|
137
|
+
"enhancetool"
|
|
131
138
|
]
|
|
132
139
|
}
|
|
133
140
|
}
|
|
@@ -137,6 +144,7 @@ npm install -g @musistudio/claude-code-router
|
|
|
137
144
|
"background": "ollama,qwen2.5-coder:latest",
|
|
138
145
|
"think": "deepseek,deepseek-reasoner",
|
|
139
146
|
"longContext": "openrouter,google/gemini-2.5-pro-preview",
|
|
147
|
+
"longContextThreshold": 60000,
|
|
140
148
|
"webSearch": "gemini,gemini-2.5-flash"
|
|
141
149
|
}
|
|
142
150
|
}
|
|
@@ -156,6 +164,16 @@ ccr code
|
|
|
156
164
|
> ccr restart
|
|
157
165
|
> ```
|
|
158
166
|
|
|
167
|
+
### 4. UI 模式
|
|
168
|
+
|
|
169
|
+
为了获得更直观的体验,您可以使用 UI 模式来管理您的配置:
|
|
170
|
+
|
|
171
|
+
```shell
|
|
172
|
+
ccr ui
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
这将打开一个基于 Web 的界面,您可以在其中轻松查看和编辑您的 `config.json` 文件。
|
|
176
|
+
|
|
159
177
|
#### Providers
|
|
160
178
|
|
|
161
179
|
`Providers` 数组是您定义要使用的不同模型提供商的地方。每个提供商对象都需要:
|
|
@@ -253,6 +271,7 @@ Transformers 允许您修改请求和响应负载,以确保与不同提供商
|
|
|
253
271
|
- `background`: 用于后台任务的模型。这可以是一个较小的本地模型以节省成本。
|
|
254
272
|
- `think`: 用于推理密集型任务(如计划模式)的模型。
|
|
255
273
|
- `longContext`: 用于处理长上下文(例如,> 60K 令牌)的模型。
|
|
274
|
+
- `longContextThreshold` (可选): 触发长上下文模型的令牌数阈值。如果未指定,默认为 60000。
|
|
256
275
|
- `webSearch`: 用于处理网络搜索任务,需要模型本身支持。如果使用`openrouter`需要在模型后面加上`:online`后缀。
|
|
257
276
|
|
|
258
277
|
您还可以使用 `/model` 命令在 Claude Code 中动态切换模型:
|
|
@@ -415,9 +434,10 @@ jobs:
|
|
|
415
434
|
- @Z*o
|
|
416
435
|
- [@congzhangzh](https://github.com/congzhangzh)
|
|
417
436
|
- @*_
|
|
437
|
+
- @Z\*m
|
|
418
438
|
|
|
419
439
|
(如果您的名字被屏蔽,请通过我的主页电子邮件与我联系,以便使用您的 GitHub 用户名进行更新。)
|
|
420
440
|
|
|
421
441
|
|
|
422
442
|
## 交流群
|
|
423
|
-
<img src="/blog/images/wechat_group.jpg" width="200" alt="wechat_group" />
|
|
443
|
+
<img src="/blog/images/wechat_group.jpg" width="200" alt="wechat_group" />
|
package/config.example.json
CHANGED
|
@@ -70,16 +70,20 @@
|
|
|
70
70
|
"name": "modelscope",
|
|
71
71
|
"api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
|
|
72
72
|
"api_key": "",
|
|
73
|
-
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
|
|
73
|
+
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507"],
|
|
74
74
|
"transformer": {
|
|
75
75
|
"use": [
|
|
76
76
|
[
|
|
77
77
|
"maxtoken",
|
|
78
78
|
{
|
|
79
|
-
"max_tokens":
|
|
79
|
+
"max_tokens": 65536
|
|
80
80
|
}
|
|
81
|
-
]
|
|
82
|
-
|
|
81
|
+
],
|
|
82
|
+
"enhancetool"
|
|
83
|
+
],
|
|
84
|
+
"Qwen/Qwen3-235B-A22B-Thinking-2507": {
|
|
85
|
+
"use": ["reasoning"]
|
|
86
|
+
}
|
|
83
87
|
}
|
|
84
88
|
},
|
|
85
89
|
{
|
|
@@ -92,9 +96,10 @@
|
|
|
92
96
|
[
|
|
93
97
|
"maxtoken",
|
|
94
98
|
{
|
|
95
|
-
"max_tokens":
|
|
99
|
+
"max_tokens": 65536
|
|
96
100
|
}
|
|
97
|
-
]
|
|
101
|
+
],
|
|
102
|
+
"enhancetool"
|
|
98
103
|
]
|
|
99
104
|
}
|
|
100
105
|
}
|
|
@@ -103,8 +108,11 @@
|
|
|
103
108
|
"default": "deepseek,deepseek-chat",
|
|
104
109
|
"background": "ollama,qwen2.5-coder:latest",
|
|
105
110
|
"think": "deepseek,deepseek-reasoner",
|
|
106
|
-
"longContext": "openrouter,google/gemini-2.5-pro-preview"
|
|
111
|
+
"longContext": "openrouter,google/gemini-2.5-pro-preview",
|
|
112
|
+
"longContextThreshold": 60000,
|
|
113
|
+
"webSearch": "gemini,gemini-2.5-flash"
|
|
107
114
|
},
|
|
108
115
|
"APIKEY": "your-secret-key",
|
|
109
|
-
"HOST": "0.0.0.0"
|
|
116
|
+
"HOST": "0.0.0.0",
|
|
117
|
+
"API_TIMEOUT_MS": 600000
|
|
110
118
|
}
|