Skip to content

Commit f2bdcb6

Browse files
feat(moonshot): implement provider with model picker, API fetching, streaming, and model metadata (#857)
* fix(moonshot): fix provider issues with model picker, refresh, and streaming - Fix duplicate ModelPicker by adding moonshot to PROVIDERS_WITH_CUSTOM_MODEL_UI - Fix HTTP 404 on Refresh Models by preserving /v1 in fetcher URL - Fix empty model list (consequence of 404 fix) - Fix 'No output generated' error by switching MoonshotHandler from OpenAICompatibleHandler (Vercel AI SDK) to OpenAiHandler (OpenAI Node SDK) which is what Moonshot's own API docs recommend - Add dedicated Moonshot fetcher with proper model ID prefixing - Update tests to match new handler implementation All 6,660 backend and 1,432 webview-ui tests pass. * feat(moonshot): add missing models with correct pricing from official docs Add kimi-k2.7-code, kimi-k2.7-code-highspeed, and kimi-k2.6 to static models map with accurate pricing from Moonshot documentation. Also fix kimi-k2.5 to correctly mark supportsImages: true. * Update webview-ui/src/components/settings/providers/Moonshot.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix(moonshot): remove fallback pricing for unknown models to match handler behavior * Bump coverage * fix(moonshot): address PR review feedback — add tests and fix inline import type - Replace inline import() type with top-level OpenAI.Chat.Completions.X in moonshot.ts - Add useSelectedModel moonshot tests (default model, router override, unknown fallback, getValidatedModelId) - Add modelCache moonshot dispatch test for fetchModelsFromProvider switch - Create Moonshot.spec.tsx with state machine tests (idle/loading/success/error states, race condition guard) --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent b132a6b commit f2bdcb6

19 files changed

Lines changed: 1365 additions & 231 deletions

File tree

packages/types/src/provider-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const dynamicProviders = [
4646
"unbound",
4747
"poe",
4848
"deepseek",
49+
"moonshot",
4950
"opencode-go",
5051
"kenari",
5152
] as const

packages/types/src/providers/moonshot.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,51 @@ export const moonshotModels = {
5656
"kimi-k2.5": {
5757
maxTokens: 16_384,
5858
contextWindow: 262_144,
59-
supportsImages: false,
59+
supportsImages: true, // Supports text, image, and video input
6060
supportsPromptCache: true,
6161
inputPrice: 0.6, // $0.60 per million tokens (cache miss)
6262
outputPrice: 3.0, // $3.00 per million tokens
6363
cacheReadsPrice: 0.1, // $0.10 per million tokens (cache hit)
6464
supportsTemperature: true,
6565
defaultTemperature: 1.0,
6666
description:
67-
"Kimi K2.5 is the latest generation of Moonshot AI's Kimi series, featuring improved reasoning capabilities and enhanced performance across diverse tasks.",
67+
"Kimi K2.5 supports text, image, and video input, thinking and non-thinking modes, and dialogue and agent tasks. Context length 256k.",
68+
},
69+
"kimi-k2.6": {
70+
maxTokens: 16_384,
71+
contextWindow: 262_144,
72+
supportsImages: true, // Native multimodal: text, image, video
73+
supportsPromptCache: true,
74+
inputPrice: 0.95, // $0.95 per million tokens (cache miss)
75+
outputPrice: 4.0, // $4.00 per million tokens
76+
cacheWritesPrice: 0, // $0 per million tokens (cache writes)
77+
cacheReadsPrice: 0.16, // $0.16 per million tokens (cache hit)
78+
description:
79+
"Kimi K2.6 is Kimi's latest and most intelligent model with stronger long-term code writing capabilities, improved instruction compliance, and self-correction. Native multimodal architecture supporting text, image, and video input. Context length 256k.",
80+
},
81+
"kimi-k2.7-code": {
82+
maxTokens: 16_384,
83+
contextWindow: 262_144,
84+
supportsImages: true, // Native multimodal: text, image, video
85+
supportsPromptCache: true,
86+
inputPrice: 0.95, // $0.95 per million tokens (cache miss)
87+
outputPrice: 4.0, // $4.00 per million tokens
88+
cacheWritesPrice: 0, // $0 per million tokens (cache writes)
89+
cacheReadsPrice: 0.19, // $0.19 per million tokens (cache hit)
90+
description:
91+
"Kimi K2.7 Code is Kimi's most intelligent Coding model for higher success rates in long context programming tasks. Native multimodal architecture supporting text, image, and video input. Context length 256k.",
92+
},
93+
"kimi-k2.7-code-highspeed": {
94+
maxTokens: 16_384,
95+
contextWindow: 262_144,
96+
supportsImages: true, // Native multimodal: text, image, video
97+
supportsPromptCache: true,
98+
inputPrice: 1.9, // $1.90 per million tokens (cache miss)
99+
outputPrice: 8.0, // $8.00 per million tokens
100+
cacheWritesPrice: 0, // $0 per million tokens (cache writes)
101+
cacheReadsPrice: 0.38, // $0.38 per million tokens (cache hit)
102+
description:
103+
"Kimi K2.7 Code HighSpeed is the high-speed version of Kimi K2.7 Code with output speed of approximately 180 Tokens/s (up to 260 Tokens/s in short context). Same model architecture, faster output. Context length 256k.",
68104
},
69105
} as const satisfies Record<string, ModelInfo>
70106

0 commit comments

Comments
 (0)