Skip to content

Commit 680f5f8

Browse files
committed
feat: add moonshotai provider
1 parent f0c5de8 commit 680f5f8

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

src/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const PROVIDERS = new Map<string, { protocol: Protocol; npm: string }>([
4343
["anthropic", { protocol: "anthropic", npm: "@ai-sdk/anthropic" }],
4444
["deepseek", { protocol: "anthropic", npm: "@ai-sdk/anthropic" }],
4545
["zai", { protocol: "openai", npm: "@ai-sdk/openai-compatible" }],
46+
["moonshotai", { protocol: "openai", npm: "@ai-sdk/openai-compatible" }],
4647
]);
4748

4849
type ModelDevEntry = {

test/models.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,63 @@ describe("buildConfigModels", () => {
455455
});
456456
});
457457

458+
it("merges Moonshot AI with OpenCode's built-in provider", () => {
459+
const modelsDevData = {
460+
moonshotai: {
461+
models: {
462+
"kimi-k3": {
463+
id: "kimi-k3",
464+
name: "Kimi K3",
465+
limit: { context: 1048576, output: 131072 },
466+
attachment: true,
467+
reasoning: true,
468+
temperature: false,
469+
tool_call: true,
470+
interleaved: { field: "reasoning_content" },
471+
modalities: {
472+
input: ["text", "image", "video"],
473+
output: ["text"],
474+
},
475+
cost: { input: 3, output: 15, cache_read: 0.3 },
476+
},
477+
},
478+
},
479+
};
480+
const hubData = {
481+
providers: {
482+
moonshotai: {
483+
models: {
484+
"kimi-k3": { display_name: "Kimi K3 from Hub" },
485+
},
486+
},
487+
},
488+
};
489+
490+
const { models, warnings } = buildConfigModels(modelsDevData, hubData);
491+
492+
expect(warnings).toEqual([]);
493+
expect(models["kimi-k3"]).toEqual({
494+
id: "kimi-k3",
495+
name: "Kimi K3",
496+
provider: {
497+
api: "https://hub.coreinfra.ai/openai/api/v1",
498+
npm: "@ai-sdk/openai-compatible",
499+
},
500+
attachment: true,
501+
reasoning: true,
502+
temperature: false,
503+
tool_call: true,
504+
modalities: {
505+
input: ["text", "image", "video"],
506+
output: ["text"],
507+
},
508+
cost: { input: 3, output: 15, cache_read: 0.3, cache_write: 0 },
509+
limit: { context: 1048576, output: 131072 },
510+
interleaved: { field: "reasoning_content" },
511+
headers: {},
512+
});
513+
});
514+
458515
it("uses Responses API for openai but Chat Completions for zai", () => {
459516
const modelsDevData = {
460517
openai: { models: { "gpt-x": { name: "GPT X" } } },

0 commit comments

Comments
 (0)