@musistudio/claude-code-router 1.0.18 → 1.0.19

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.
Files changed (3) hide show
  1. package/README.md +96 -2
  2. package/dist/cli.js +450 -409
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -24,7 +24,7 @@ npm install -g @musistudio/claude-code-router
24
24
  ccr code
25
25
  ```
26
26
 
27
- 4. Configure routing[optional]
27
+ 4. Configure routing
28
28
  Set up your `~/.claude-code-router/config.json` file like this:
29
29
 
30
30
  ```json
@@ -85,6 +85,23 @@ ccr code
85
85
  "transformer": {
86
86
  "use": ["deepseek"]
87
87
  }
88
+ },
89
+ {
90
+ "name": "siliconflow",
91
+ // IMPORTANT: api_base_url must be a complete (full) URL.
92
+ "api_base_url": "https://api.siliconflow.cn/v1/chat/completions",
93
+ "api_key": "sk-xxx",
94
+ "models": ["moonshotai/Kimi-K2-Instruct"],
95
+ "transformer": {
96
+ "use": [
97
+ [
98
+ "maxtoken",
99
+ {
100
+ "max_tokens": 16384 // for siliconflow max_tokens
101
+ }
102
+ ]
103
+ ]
104
+ }
88
105
  }
89
106
  ],
90
107
  "Router": {
@@ -113,6 +130,79 @@ ccr code
113
130
  `/model openrouter,anthropic/claude-3.5-sonnet`
114
131
  This will use the anthropic/claude-3.5-sonnet model provided by OpenRouter to handle all subsequent tasks.
115
132
 
133
+ 5. About transformer
134
+ `transformer` is used to convert requests and responses for different vendors. For different vendors, we can configure different transformers.
135
+
136
+ For example, in the following case, we use the `openrouter` transformer for the OpenRouter vendor. This transformer removes the `cache_control` parameter (mainly used to adapt Claude's prompt cache) from the request for models other than Claude. In the response, it adapts the reasoning field.
137
+ ```json
138
+ {
139
+ "name": "openrouter",
140
+ "api_base_url": "https://openrouter.ai/api/v1/chat/completions",
141
+ "api_key": "",
142
+ "models": [
143
+ "google/gemini-2.5-pro-preview",
144
+ "anthropic/claude-sonnet-4",
145
+ "anthropic/claude-3.5-sonnet",
146
+ "anthropic/claude-3.7-sonnet:thinking",
147
+ "deepseek/deepseek-chat-v3-0324"
148
+ ],
149
+ "transformer": {
150
+ "use": [
151
+ "openrouter"
152
+ ]
153
+ }
154
+ }
155
+ ```
156
+ You can also configure transformers for different models of the same vendor. For instance, in the following example, we use the `deepseek` transformer for the DeepSeek vendor. This transformer sets the maximum value of `max_tokens` to `8192` in the request, and in the response, it adapts the `reasoning_content` field. Additionally, for the `deepseek-chat` model, we use the `tooluse` transformer, which optimizes the tool call for the `deepseek-v3` model using the `tool_choice` parameter (mainly because deepseek-r1 does not support the tool_choice parameter).
157
+ ```json
158
+ {
159
+ "name": "deepseek",
160
+ "api_base_url": "https://api.deepseek.com/chat/completions",
161
+ "api_key": "",
162
+ "models": [
163
+ "deepseek-chat",
164
+ "deepseek-reasoner"
165
+ ],
166
+ "transformer": {
167
+ "use": [
168
+ "deepseek"
169
+ ],
170
+ "deepseek-chat": {
171
+ "use": [
172
+ "tooluse"
173
+ ]
174
+ }
175
+ }
176
+ }
177
+ ```
178
+ Currently, the following transformers are available:
179
+
180
+ - deepseek
181
+
182
+ - gemini
183
+
184
+ - maxtoken
185
+
186
+ - openrouter
187
+
188
+ - tooluse
189
+
190
+ - gemini-cli (experimental, unofficial support: https://gist.github.com/musistudio/1c13a65f35916a7ab690649d3df8d1cd)
191
+
192
+ You can configure custom transformers in the `config.json` file using the `transformers` field, for example:
193
+ ```json
194
+ {
195
+ "transformers": [
196
+ {
197
+ "path": "$HOME/.claude-code-router/plugins/gemini-cli.js",
198
+ "options": {
199
+ "project": "xxx"
200
+ }
201
+ }
202
+ ]
203
+ }
204
+ ```
205
+
116
206
  ## Features
117
207
 
118
208
  - [x] Support change models
@@ -248,4 +338,8 @@ Thanks to the following sponsors for supporting the continued development of thi
248
338
  @\*晖 (可通过主页邮箱联系我修改 github 用户名)
249
339
  @\*敏 (可通过主页邮箱联系我修改 github 用户名)
250
340
  @Z\*z (可通过主页邮箱联系我修改 github 用户名)
251
- @\*然 (可通过主页邮箱联系我修改 github 用户名)
341
+ @\*然 (可通过主页邮箱联系我修改 github 用户名)
342
+ [@cluic](https://github.com/cluic)
343
+ @\*苗 (可通过主页邮箱联系我修改 github 用户名)
344
+ [@PromptExpert](https://github.com/PromptExpert)
345
+ @\*应 (可通过主页邮箱联系我修改 github 用户名)