update qwen3-coder example

This commit is contained in:
musistudio
2025-07-25 17:19:52 +08:00
parent 179bab605e
commit 6883fff352
3 changed files with 124 additions and 119 deletions

View File

@@ -36,6 +36,7 @@ npm install -g @musistudio/claude-code-router
Create and configure your `~/.claude-code-router/config.json` file. For more details, you can refer to `config.example.json`. Create and configure your `~/.claude-code-router/config.json` file. For more details, you can refer to `config.example.json`.
The `config.json` file has several key sections: The `config.json` file has several key sections:
- **`PROXY_URL`** (optional): You can set a proxy for API requests, for example: `"PROXY_URL": "http://127.0.0.1:7890"`. - **`PROXY_URL`** (optional): You can set a proxy for API requests, for example: `"PROXY_URL": "http://127.0.0.1:7890"`.
- **`LOG`** (optional): You can enable logging by setting it to `true`. The log file will be located at `$HOME/.claude-code-router.log`. - **`LOG`** (optional): You can enable logging by setting it to `true`. The log file will be located at `$HOME/.claude-code-router.log`.
- **`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"`. - **`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"`.
@@ -112,9 +113,10 @@ Here is a comprehensive example:
[ [
"maxtoken", "maxtoken",
{ {
"max_tokens": 8192 "max_tokens": 65536
} }
] ],
"enhancetool"
] ]
} }
}, },
@@ -128,9 +130,10 @@ Here is a comprehensive example:
[ [
"maxtoken", "maxtoken",
{ {
"max_tokens": 8192 "max_tokens": 65536
} }
] ],
"enhancetool"
] ]
} }
} }
@@ -145,7 +148,6 @@ Here is a comprehensive example:
} }
``` ```
### 3. Running Claude Code with the Router ### 3. Running Claude Code with the Router
Start Claude Code using the router: Start Claude Code using the router:
@@ -155,6 +157,7 @@ ccr code
``` ```
> **Note**: After modifying the configuration file, you need to restart the service for the changes to take effect: > **Note**: After modifying the configuration file, you need to restart the service for the changes to take effect:
>
> ```shell > ```shell
> ccr restart > ccr restart
> ``` > ```
@@ -188,6 +191,7 @@ Transformers allow you to modify the request and response payloads to ensure com
} }
``` ```
- **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. - **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.
```json ```json
{ {
"name": "deepseek", "name": "deepseek",
@@ -258,7 +262,6 @@ The `Router` object defines which model to use for different scenarios:
- `longContext`: A model for handling long contexts (e.g., > 60K tokens). - `longContext`: A model for handling long contexts (e.g., > 60K tokens).
- `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. - `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.
You can also switch models dynamically in Claude Code with the `/model` command: You can also switch models dynamically in Claude Code with the `/model` command:
`/model provider_name,model_name` `/model provider_name,model_name`
Example: `/model openrouter,anthropic/claude-3.5-sonnet` Example: `/model openrouter,anthropic/claude-3.5-sonnet`
@@ -290,11 +293,11 @@ Here is an example of a `custom-router.js` based on `custom-router.example.js`:
* @returns {Promise<string|null>} - A promise that resolves to the "provider,model_name" string, or null to use the default router. * @returns {Promise<string|null>} - A promise that resolves to the "provider,model_name" string, or null to use the default router.
*/ */
module.exports = async function router(req, config) { module.exports = async function router(req, config) {
const userMessage = req.body.messages.find(m => m.role === 'user')?.content; const userMessage = req.body.messages.find((m) => m.role === "user")?.content;
if (userMessage && userMessage.includes('explain this code')) { if (userMessage && userMessage.includes("explain this code")) {
// Use a powerful model for code explanation // Use a powerful model for code explanation
return 'openrouter,anthropic/claude-3.5-sonnet'; return "openrouter,anthropic/claude-3.5-sonnet";
} }
// Fallback to the default router configuration // Fallback to the default router configuration
@@ -302,7 +305,6 @@ module.exports = async function router(req, config) {
}; };
``` ```
## 🤖 GitHub Actions ## 🤖 GitHub Actions
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: 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:
@@ -387,39 +389,38 @@ A huge thank you to all our sponsors for their generous support!
- @Simon Leischnig - @Simon Leischnig
- [@duanshuaimin](https://github.com/duanshuaimin) - [@duanshuaimin](https://github.com/duanshuaimin)
- [@vrgitadmin](https://github.com/vrgitadmin) - [@vrgitadmin](https://github.com/vrgitadmin)
- @*o - @\*o
- [@ceilwoo](https://github.com/ceilwoo) - [@ceilwoo](https://github.com/ceilwoo)
- @*说 - @\*说
- @*更 - @\*更
- @K*g - @K\*g
- @R*R - @R\*R
- [@bobleer](https://github.com/bobleer) - [@bobleer](https://github.com/bobleer)
- @*苗 - @\*苗
- @*划 - @\*划
- [@Clarence-pan](https://github.com/Clarence-pan) - [@Clarence-pan](https://github.com/Clarence-pan)
- [@carter003](https://github.com/carter003) - [@carter003](https://github.com/carter003)
- @S*r - @S\*r
- @*晖 - @\*晖
- @*敏 - @\*敏
- @Z*z - @Z\*z
- @*然 - @\*然
- [@cluic](https://github.com/cluic) - [@cluic](https://github.com/cluic)
- @*苗 - @\*苗
- [@PromptExpert](https://github.com/PromptExpert) - [@PromptExpert](https://github.com/PromptExpert)
- @*应 - @\*应
- [@yusnake](https://github.com/yusnake) - [@yusnake](https://github.com/yusnake)
- @*飞 - @\*飞
- @董* - @董\*
- @*汀 - @\*汀
- @*涯 - @\*涯
- @*:- - @\*:-
- @**磊 - @\*\*磊
- @*琢 - @\*琢
- @*成 - @\*成
- @Z*o - @Z\*o
- @*琨 - @\*琨
- [@congzhangzh](https://github.com/congzhangzh) - [@congzhangzh](https://github.com/congzhangzh)
- @*_ - @\*\_
(If your name is masked, please contact me via my homepage email to update it with your GitHub username.) (If your name is masked, please contact me via my homepage email to update it with your GitHub username.)

View File

@@ -109,9 +109,10 @@ npm install -g @musistudio/claude-code-router
[ [
"maxtoken", "maxtoken",
{ {
"max_tokens": 8192 "max_tokens": 65536
} }
] ],
"enhancetool"
] ]
} }
}, },
@@ -125,9 +126,10 @@ npm install -g @musistudio/claude-code-router
[ [
"maxtoken", "maxtoken",
{ {
"max_tokens": 8192 "max_tokens": 65536
} }
] ],
"enhancetool"
] ]
} }
} }

View File

@@ -76,9 +76,10 @@
[ [
"maxtoken", "maxtoken",
{ {
"max_tokens": 8192 "max_tokens": 65536
} }
] ],
"enhancetool"
] ]
} }
}, },
@@ -92,9 +93,10 @@
[ [
"maxtoken", "maxtoken",
{ {
"max_tokens": 8192 "max_tokens": 65536
} }
] ],
"enhancetool"
] ]
} }
} }