@musistudio/claude-code-router 1.0.36 → 1.0.38
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 +12 -4
- package/README_zh.md +11 -4
- package/dist/cli.js +1098 -438
- package/dist/index.html +123 -54
- package/package.json +2 -2
- package/config.example.json +0 -119
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Claude Code Router
|
|
2
2
|
|
|
3
|
+
I am seeking funding support for this project to better sustain its development. If you have any ideas, feel free to reach out to me: [m@musiiot.top](mailto:m@musiiot.top)
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
[中文版](README_zh.md)
|
|
4
7
|
|
|
5
8
|
> A powerful tool to route Claude Code requests to different models and customize any request.
|
|
@@ -38,7 +41,11 @@ Create and configure your `~/.claude-code-router/config.json` file. For more det
|
|
|
38
41
|
The `config.json` file has several key sections:
|
|
39
42
|
|
|
40
43
|
- **`PROXY_URL`** (optional): You can set a proxy for API requests, for example: `"PROXY_URL": "http://127.0.0.1:7890"`.
|
|
41
|
-
- **`LOG`** (optional): You can enable logging by setting it to `true`.
|
|
44
|
+
- **`LOG`** (optional): You can enable logging by setting it to `true`. When set to `false`, no log files will be created. Default is `true`.
|
|
45
|
+
- **`LOG_LEVEL`** (optional): Set the logging level. Available options are: `"fatal"`, `"error"`, `"warn"`, `"info"`, `"debug"`, `"trace"`. Default is `"info"`.
|
|
46
|
+
- **Logging Systems**: The Claude Code Router uses two separate logging systems:
|
|
47
|
+
- **Server-level logs**: HTTP requests, API calls, and server events are logged using pino in the `~/.claude-code-router/logs/` directory with filenames like `ccr-*.log`
|
|
48
|
+
- **Application-level logs**: Routing decisions and business logic events are logged in `~/.claude-code-router/claude-code-router.log`
|
|
42
49
|
- **`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
50
|
- **`HOST`** (optional): You can set the host address for the server. If `APIKEY` is not set, the host will be forced to `127.0.0.1` for security reasons to prevent unauthorized access. Example: `"HOST": "0.0.0.0"`.
|
|
44
51
|
- **`NON_INTERACTIVE_MODE`** (optional): When set to `true`, enables compatibility with non-interactive environments like GitHub Actions, Docker containers, or other CI/CD systems. This sets appropriate environment variables (`CI=true`, `FORCE_COLOR=0`, etc.) and configures stdin handling to prevent the process from hanging in automated environments. Example: `"NON_INTERACTIVE_MODE": true`.
|
|
@@ -312,6 +319,7 @@ Transformers allow you to modify the request and response payloads to ensure com
|
|
|
312
319
|
- `cleancache`: Clears the `cache_control` field from requests.
|
|
313
320
|
- `vertex-gemini`: Handles the Gemini API using Vertex authentication.
|
|
314
321
|
- `qwen-cli` (experimental): Unofficial support for qwen3-coder-plus model via Qwen CLI [qwen-cli.js](https://gist.github.com/musistudio/f5a67841ced39912fd99e42200d5ca8b).
|
|
322
|
+
- `rovo-cli` (experimental): Unofficial support for gpt-5 via Atlassian Rovo Dev CLI [rovo-cli.js](https://gist.github.com/SaseQ/c2a20a38b11276537ec5332d1f7a5e53).
|
|
315
323
|
|
|
316
324
|
**Custom Transformers:**
|
|
317
325
|
|
|
@@ -321,7 +329,7 @@ You can also create your own transformers and load them via the `transformers` f
|
|
|
321
329
|
{
|
|
322
330
|
"transformers": [
|
|
323
331
|
{
|
|
324
|
-
"path": "
|
|
332
|
+
"path": "/User/xxx/.claude-code-router/plugins/gemini-cli.js",
|
|
325
333
|
"options": {
|
|
326
334
|
"project": "xxx"
|
|
327
335
|
}
|
|
@@ -353,7 +361,7 @@ In your `config.json`:
|
|
|
353
361
|
|
|
354
362
|
```json
|
|
355
363
|
{
|
|
356
|
-
"CUSTOM_ROUTER_PATH": "
|
|
364
|
+
"CUSTOM_ROUTER_PATH": "/User/xxx/.claude-code-router/custom-router.js"
|
|
357
365
|
}
|
|
358
366
|
```
|
|
359
367
|
|
|
@@ -362,7 +370,7 @@ The custom router file must be a JavaScript module that exports an `async` funct
|
|
|
362
370
|
Here is an example of a `custom-router.js` based on `custom-router.example.js`:
|
|
363
371
|
|
|
364
372
|
```javascript
|
|
365
|
-
//
|
|
373
|
+
// /User/xxx/.claude-code-router/custom-router.js
|
|
366
374
|
|
|
367
375
|
/**
|
|
368
376
|
* A custom router function to determine which model to use based on the request.
|
package/README_zh.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Claude Code Router
|
|
2
2
|
|
|
3
|
+
我正在为该项目寻求资金支持,以更好地维持其发展。如果您有任何想法,请随时与我联系: [m@musiiot.top](mailto:m@musiiot.top)
|
|
4
|
+
|
|
3
5
|
> 一款强大的工具,可将 Claude Code 请求路由到不同的模型,并自定义任何请求。
|
|
4
6
|
|
|
5
7
|

|
|
@@ -35,7 +37,11 @@ npm install -g @musistudio/claude-code-router
|
|
|
35
37
|
|
|
36
38
|
`config.json` 文件有几个关键部分:
|
|
37
39
|
- **`PROXY_URL`** (可选): 您可以为 API 请求设置代理,例如:`"PROXY_URL": "http://127.0.0.1:7890"`。
|
|
38
|
-
- **`LOG`** (可选): 您可以通过将其设置为 `true`
|
|
40
|
+
- **`LOG`** (可选): 您可以通过将其设置为 `true` 来启用日志记录。当设置为 `false` 时,将不会创建日志文件。默认值为 `true`。
|
|
41
|
+
- **`LOG_LEVEL`** (可选): 设置日志级别。可用选项包括:`"fatal"`、`"error"`、`"warn"`、`"info"`、`"debug"`、`"trace"`。默认值为 `"info"`。
|
|
42
|
+
- **日志系统**: Claude Code Router 使用两个独立的日志系统:
|
|
43
|
+
- **服务器级别日志**: HTTP 请求、API 调用和服务器事件使用 pino 记录在 `~/.claude-code-router/logs/` 目录中,文件名类似于 `ccr-*.log`
|
|
44
|
+
- **应用程序级别日志**: 路由决策和业务逻辑事件记录在 `~/.claude-code-router/claude-code-router.log` 文件中
|
|
39
45
|
- **`APIKEY`** (可选): 您可以设置一个密钥来进行身份验证。设置后,客户端请求必须在 `Authorization` 请求头 (例如, `Bearer your-secret-key`) 或 `x-api-key` 请求头中提供此密钥。例如:`"APIKEY": "your-secret-key"`。
|
|
40
46
|
- **`HOST`** (可选): 您可以设置服务的主机地址。如果未设置 `APIKEY`,出于安全考虑,主机地址将强制设置为 `127.0.0.1`,以防止未经授权的访问。例如:`"HOST": "0.0.0.0"`。
|
|
41
47
|
- **`NON_INTERACTIVE_MODE`** (可选): 当设置为 `true` 时,启用与非交互式环境(如 GitHub Actions、Docker 容器或其他 CI/CD 系统)的兼容性。这会设置适当的环境变量(`CI=true`、`FORCE_COLOR=0` 等)并配置 stdin 处理,以防止进程在自动化环境中挂起。例如:`"NON_INTERACTIVE_MODE": true`。
|
|
@@ -285,6 +291,7 @@ Transformers 允许您修改请求和响应负载,以确保与不同提供商
|
|
|
285
291
|
- `cleancache`: 清除请求中的 `cache_control` 字段。
|
|
286
292
|
- `vertex-gemini`: 处理使用 vertex 鉴权的 gemini api。
|
|
287
293
|
- `qwen-cli` (实验性): 通过 Qwen CLI [qwen-cli.js](https://gist.github.com/musistudio/f5a67841ced39912fd99e42200d5ca8b) 对 qwen3-coder-plus 的非官方支持。
|
|
294
|
+
- `rovo-cli` (experimental): 通过 Atlassian Rovo Dev CLI [rovo-cli.js](https://gist.github.com/SaseQ/c2a20a38b11276537ec5332d1f7a5e53) 对 GPT-5 的非官方支持。
|
|
288
295
|
|
|
289
296
|
**自定义 Transformer:**
|
|
290
297
|
|
|
@@ -294,7 +301,7 @@ Transformers 允许您修改请求和响应负载,以确保与不同提供商
|
|
|
294
301
|
{
|
|
295
302
|
"transformers": [
|
|
296
303
|
{
|
|
297
|
-
"path": "
|
|
304
|
+
"path": "/User/xxx/.claude-code-router/plugins/gemini-cli.js",
|
|
298
305
|
"options": {
|
|
299
306
|
"project": "xxx"
|
|
300
307
|
}
|
|
@@ -326,7 +333,7 @@ Transformers 允许您修改请求和响应负载,以确保与不同提供商
|
|
|
326
333
|
|
|
327
334
|
```json
|
|
328
335
|
{
|
|
329
|
-
"CUSTOM_ROUTER_PATH": "
|
|
336
|
+
"CUSTOM_ROUTER_PATH": "/User/xxx/.claude-code-router/custom-router.js"
|
|
330
337
|
}
|
|
331
338
|
```
|
|
332
339
|
|
|
@@ -335,7 +342,7 @@ Transformers 允许您修改请求和响应负载,以确保与不同提供商
|
|
|
335
342
|
这是一个基于 `custom-router.example.js` 的 `custom-router.js` 示例:
|
|
336
343
|
|
|
337
344
|
```javascript
|
|
338
|
-
//
|
|
345
|
+
// /User/xxx/.claude-code-router/custom-router.js
|
|
339
346
|
|
|
340
347
|
/**
|
|
341
348
|
* 一个自定义路由函数,用于根据请求确定使用哪个模型。
|