Skip to content

Commit 588ee19

Browse files
鲁工鲁工
authored andcommitted
feat: add Kimi Code coding-plan subscription provider
Kimi's coding plan is a third platform besides the two open platforms: keys come from the kimi.com member console and only work on api.kimi.com/coding (Anthropic-compatible, x-api-key auth per the official Claude Code guide at kimi.com/code/docs). Models and context are tier-gated: kimi-for-coding for all tiers, k3 (256K) for Moderato+, k3[1m] (1M) and kimi-for-coding-highspeed for Allegretto+ - k3[1m] is the literal model id the vendor documents. The provider is named kimi-plan (matching step-plan/seed-plan) because the natural name collides: 'kimi-code' has aliased the international K2.7 Code since v1.7.1 and repurposing it would silently reroute existing users; a regression test now pins those legacy aliases. Output caps mirror the same models on the open platform (K3 max 1048576, K2.7 Code 32768).
1 parent fb3c25d commit 588ee19

8 files changed

Lines changed: 231 additions & 3 deletions

File tree

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ KIMI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxx
2828
# 使用 kimi-cn / kimi-cn-k3 别名,与国际站 Key 不互通
2929
KIMI_CN_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxx
3030

31+
# ============================================
32+
# Kimi Code API (会员 coding 订阅)
33+
# ============================================
34+
# 从 https://www.kimi.com/code/console 获取(会员订阅,与开放平台 Key 不互通)
35+
# 使用 kimi-code / kimi-for-coding 别名;模型与上下文按会员档位限权
36+
KIMI_CODE_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxx
37+
3138
# ============================================
3239
# MiniMax CN / Token Plan API
3340
# ============================================

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ ccmr claude --print --output-format json "你的问题"
191191
| `kimi-cn-k2.6` | - | Kimi K2.6 | Moonshot(国内开放平台) |
192192
| `kimi-cn-k2.7-code` | - | Kimi K2.7 Code | Moonshot(国内开放平台) |
193193
| `kimi-cn-k2.7-code-highspeed` | - | Kimi K2.7 Code HighSpeed | Moonshot(国内开放平台) |
194+
| `kimi-plan-k3-1m` | `kimi-plan` | Kimi K3 1M(Allegretto 及以上) | Kimi Code 会员订阅 |
195+
| `kimi-plan-k3` | - | Kimi K3 256K(Moderato 及以上) | Kimi Code 会员订阅 |
196+
| `kimi-plan-for-coding` | `kimi-for-coding` | Kimi K2.7 Code(全档位) | Kimi Code 会员订阅 |
197+
| `kimi-plan-for-coding-highspeed` | `kimi-plan-highspeed` | Kimi K2.7 Code HighSpeed(Allegretto 及以上) | Kimi Code 会员订阅 |
194198
| `minimax-m3` | `minimax`, `minimax-cn`, `mm` | MiniMax M3 | MiniMax CN |
195199
| `minimax-global-m3` | `minimax-global`, `minimax-io` | MiniMax M3 | MiniMax Global |
196200
| `qwen3.5-plus` | `qwen`, `qwen3.5`, `tongyi` | Qwen3.5 Plus | 阿里云 |
@@ -221,6 +225,8 @@ ccmr claude --print --output-format json "你的问题"
221225
| Kimi K3 (国际站 / 国内) | 1M | 1M(默认 128K) |
222226
| Kimi K2.6 (国际站 / 国内) | 256K | 32K |
223227
| Kimi K2.7 Code / HighSpeed (国际站 / 国内) | 256K | 32K |
228+
| Kimi K3 (Coding Plan `kimi-plan-k3-1m` / `kimi-plan-k3`) | 1M / 256K(按档位) | 1M / 128K |
229+
| Kimi K2.7 Code / HighSpeed (Coding Plan) | 256K | 32K |
224230
| MiniMax M3 (CN / Global) | 1M | 128K |
225231
| Qwen3.5 Plus | 1M | 64K |
226232
| Qwen3.5 Flash | 1M | 64K |
@@ -262,6 +268,7 @@ claude mcp add tavily -- npx -y tavily-mcp # 也可用 Exa、Brave Search 等
262268
DEEPSEEK_API_KEY=sk-xxx # https://platform.deepseek.com/
263269
KIMI_API_KEY=sk-xxx # Kimi 国际站: https://platform.kimi.ai/
264270
KIMI_CN_API_KEY=sk-xxx # Kimi 国内开放平台(与国际站不互通): https://platform.kimi.com/
271+
KIMI_CODE_API_KEY=sk-xxx # Kimi Code 会员 coding 订阅(与开放平台不互通): https://www.kimi.com/code/console
265272
MINIMAX_API_KEY=xxx # MiniMax CN / Token Plan: https://platform.minimaxi.com/
266273
MINIMAX_GLOBAL_API_KEY=xxx # MiniMax Global: https://platform.minimax.io/
267274
QWEN_API_KEY=sk-xxx # https://dashscope.console.aliyun.com/
@@ -520,6 +527,11 @@ DeepSeek Anthropic 兼容接口会忽略 `metadata` 字段,但某些 Claude Co
520527

521528
## 更新日志
522529

530+
### v1.10.0
531+
532+
- 新增 Kimi Code 会员 coding 订阅入口(`api.kimi.com/coding`,Key 来自 [kimi.com 会员控制台](https://www.kimi.com/code/console),与开放平台不互通):需配置 `KIMI_CODE_API_KEY`,提供 `kimi-plan-k3-1m`(别名 `kimi-plan`,Allegretto 及以上)、`kimi-plan-k3`(Moderato 及以上,256K)、`kimi-plan-for-coding`(别名 `kimi-for-coding`,全档位)、`kimi-plan-for-coding-highspeed`;模型与上下文按会员档位限权
533+
- 兼容性说明:既有别名 `kimi-code` / `kimi-code-highspeed` 仍指向国际站 K2.7 Code 模型,含义不变;订阅版统一使用 `kimi-plan` 前缀(与 `step-plan` / `seed-plan` 命名一致)
534+
523535
### v1.9.1
524536

525537
- `ccmr claude` 启动模型缺少 API Key 时的指引拆分:若网关本身健康且有其他可用模型,直接提示 `ccmr use <可用模型>`(或 `--model` 单次指定、补配该模型的 Key),不再误导用户去 `ccmr stop` + `ccmr init` 重建配置;"stop + init"指引仅保留给网关完全无 Key 或不认识该模型的场景

dist/config.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/config.js

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/config.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "claude-code-model-router",
3-
"version": "1.9.1",
3+
"version": "1.10.0",
44
"description": "A lightweight API gateway for routing Claude Code requests to multiple AI models",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/config.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,45 @@ export const DEFAULT_CONFIG: RouterConfig = {
112112
},
113113
},
114114
},
115+
'kimi-plan': {
116+
display_name: 'Kimi Code',
117+
provider: 'moonshot-code',
118+
// Kimi 会员 coding 订阅的 Anthropic 接入点。Key 来自 kimi.com 会员控制台,
119+
// 与开放平台(moonshot.cn / .ai)互不相通;模型与上下文按会员档位限权。
120+
base_url: 'https://api.kimi.com/coding',
121+
api_key_env: 'KIMI_CODE_API_KEY',
122+
auth_header: 'x-api-key',
123+
auth_type: 'api_key',
124+
supports_streaming: true,
125+
supports_tools: true,
126+
default_variant: 'k3-1m',
127+
variants: {
128+
'k3-1m': {
129+
display_name: 'Kimi K3 1M (Coding Plan)',
130+
model_id: 'k3[1m]',
131+
max_tokens: 1048576,
132+
context_window: 1048576,
133+
},
134+
k3: {
135+
display_name: 'Kimi K3 256K (Coding Plan)',
136+
model_id: 'k3',
137+
max_tokens: 131072,
138+
context_window: 262144,
139+
},
140+
'for-coding': {
141+
display_name: 'Kimi K2.7 Code (Coding Plan)',
142+
model_id: 'kimi-for-coding',
143+
max_tokens: 32768,
144+
context_window: 262144,
145+
},
146+
'for-coding-highspeed': {
147+
display_name: 'Kimi K2.7 Code HighSpeed (Coding Plan)',
148+
model_id: 'kimi-for-coding-highspeed',
149+
max_tokens: 32768,
150+
context_window: 262144,
151+
},
152+
},
153+
},
115154
minimax: {
116155
display_name: 'MiniMax CN',
117156
provider: 'minimax-cn',
@@ -453,6 +492,13 @@ export const DEFAULT_CONFIG: RouterConfig = {
453492
'kimi-cn-k2.6': 'kimi-cn-k2.6',
454493
'kimi-cn-k2.7-code': 'kimi-cn-k2.7-code',
455494
'kimi-cn-k2.7-code-highspeed': 'kimi-cn-k2.7-code-highspeed',
495+
'kimi-plan': 'kimi-plan-k3-1m',
496+
'kimi-plan-k3-1m': 'kimi-plan-k3-1m',
497+
'kimi-plan-k3': 'kimi-plan-k3',
498+
'kimi-for-coding': 'kimi-plan-for-coding',
499+
'kimi-plan-for-coding': 'kimi-plan-for-coding',
500+
'kimi-plan-for-coding-highspeed': 'kimi-plan-for-coding-highspeed',
501+
'kimi-plan-highspeed': 'kimi-plan-for-coding-highspeed',
456502
minimax: 'minimax-m3',
457503
'minimax-cn': 'minimax-m3',
458504
'minimax-m3': 'minimax-m3',
@@ -1146,6 +1192,37 @@ providers:
11461192
max_tokens: 32768
11471193
context_window: 262144
11481194
1195+
# Kimi 会员 coding 订阅(kimi.com 会员控制台发 Key,与开放平台不互通;按档位限权)
1196+
kimi-plan:
1197+
display_name: Kimi Code
1198+
provider: moonshot-code
1199+
base_url: https://api.kimi.com/coding
1200+
api_key_env: KIMI_CODE_API_KEY
1201+
auth_header: x-api-key
1202+
auth_type: api_key
1203+
default_variant: k3-1m
1204+
variants:
1205+
k3-1m:
1206+
display_name: "Kimi K3 1M (Coding Plan)"
1207+
model_id: "k3[1m]"
1208+
max_tokens: 1048576
1209+
context_window: 1048576
1210+
k3:
1211+
display_name: "Kimi K3 256K (Coding Plan)"
1212+
model_id: k3
1213+
max_tokens: 131072
1214+
context_window: 262144
1215+
for-coding:
1216+
display_name: "Kimi K2.7 Code (Coding Plan)"
1217+
model_id: kimi-for-coding
1218+
max_tokens: 32768
1219+
context_window: 262144
1220+
for-coding-highspeed:
1221+
display_name: "Kimi K2.7 Code HighSpeed (Coding Plan)"
1222+
model_id: kimi-for-coding-highspeed
1223+
max_tokens: 32768
1224+
context_window: 262144
1225+
11491226
minimax:
11501227
display_name: MiniMax CN
11511228
provider: minimax-cn
@@ -1423,6 +1500,13 @@ aliases:
14231500
kimi-cn-k2.6: kimi-cn-k2.6
14241501
kimi-cn-k2.7-code: kimi-cn-k2.7-code
14251502
kimi-cn-k2.7-code-highspeed: kimi-cn-k2.7-code-highspeed
1503+
kimi-plan: kimi-plan-k3-1m
1504+
kimi-plan-k3-1m: kimi-plan-k3-1m
1505+
kimi-plan-k3: kimi-plan-k3
1506+
kimi-for-coding: kimi-plan-for-coding
1507+
kimi-plan-for-coding: kimi-plan-for-coding
1508+
kimi-plan-for-coding-highspeed: kimi-plan-for-coding-highspeed
1509+
kimi-plan-highspeed: kimi-plan-for-coding-highspeed
14261510
minimax: minimax-m3
14271511
minimax-cn: minimax-m3
14281512
minimax-m3: minimax-m3
@@ -1509,6 +1593,9 @@ KIMI_API_KEY=
15091593
# Kimi / Moonshot 国内开放平台 - https://platform.kimi.com/ (原 platform.moonshot.cn)
15101594
KIMI_CN_API_KEY=
15111595
1596+
# Kimi Code 会员 coding 订阅 - https://www.kimi.com/code/console (与开放平台 Key 不互通)
1597+
KIMI_CODE_API_KEY=
1598+
15121599
# MiniMax CN / Token Plan - https://platform.minimaxi.com/
15131600
MINIMAX_API_KEY=
15141601

tests/config.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,41 @@ describe('Kimi K3: international variant and CN-platform provider', () => {
114114
});
115115
});
116116

117+
describe('Kimi Code: coding-plan subscription provider', () => {
118+
const manager = new ConfigManager(null);
119+
const config = manager.getConfig();
120+
121+
it('exposes the coding-plan endpoint as its own provider and key', () => {
122+
// Keys come from the kimi.com member console and only work on
123+
// api.kimi.com/coding - a third platform besides moonshot.cn/.ai.
124+
const model = config.models['kimi-plan-k3-1m'];
125+
expect(model).toBeDefined();
126+
expect(model.model_id).toBe('k3[1m]');
127+
expect(model.base_url).toBe('https://api.kimi.com/coding');
128+
expect(model.api_key_env).toBe('KIMI_CODE_API_KEY');
129+
expect(model.auth_type).toBe('api_key');
130+
expect(model.context_window).toBe(1048576);
131+
expect(manager.resolveModelName('kimi-plan')).toBe('kimi-plan-k3-1m');
132+
});
133+
134+
it('carries the tier-gated variants with the plan model ids', () => {
135+
expect(config.models['kimi-plan-k3'].model_id).toBe('k3');
136+
expect(config.models['kimi-plan-k3'].context_window).toBe(262144);
137+
expect(config.models['kimi-plan-for-coding'].model_id).toBe('kimi-for-coding');
138+
expect(config.models['kimi-plan-for-coding-highspeed'].model_id).toBe(
139+
'kimi-for-coding-highspeed'
140+
);
141+
expect(manager.resolveModelName('kimi-for-coding')).toBe('kimi-plan-for-coding');
142+
});
143+
144+
it('keeps the legacy kimi-code aliases on the international K2.7 models', () => {
145+
// 'kimi-code' has meant the international K2.7 Code since v1.7.1 -
146+
// the subscription provider must not silently repurpose it.
147+
expect(manager.resolveModelName('kimi-code')).toBe('kimi-k2.7-code');
148+
expect(manager.resolveModelName('kimi-code-highspeed')).toBe('kimi-k2.7-code-highspeed');
149+
});
150+
});
151+
117152
describe('ConfigManager: user config merging', () => {
118153
it('fails closed when an explicit config path does not exist', () => {
119154
expect(() => new ConfigManager('/definitely-missing/ccmr-models.yaml')).toThrow(

0 commit comments

Comments
 (0)