Skip to content

Commit 0812a97

Browse files
Merge branch 'main' into feat/kimi-code
2 parents ccf1597 + 6fec173 commit 0812a97

6 files changed

Lines changed: 126 additions & 0 deletions

File tree

packages/types/src/__tests__/lite-llm.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe("LiteLLM preserveReasoning model detection", () => {
1212
})
1313

1414
it("matches provider-prefixed routed model names by their final segment", () => {
15+
expect(isLiteLLMPreserveReasoningModel("kimi-k3")).toBe(true)
1516
expect(isLiteLLMPreserveReasoningModel("deepseek/deepseek-reasoner")).toBe(true)
1617
expect(isLiteLLMPreserveReasoningModel("bedrock/moonshot.kimi-k2-thinking")).toBe(true)
1718
expect(isLiteLLMPreserveReasoningModel("fireworks_ai/accounts/fireworks/models/kimi-k2p7-code")).toBe(true)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import type { ModelInfo } from "../model.js"
2+
import { MOONSHOT_DEFAULT_TEMPERATURE, moonshotDefaultModelId, moonshotModels } from "../providers/moonshot.js"
3+
4+
const modelEntries: [string, ModelInfo][] = Object.entries(moonshotModels)
5+
const modelInfos: ModelInfo[] = Object.values(moonshotModels)
6+
7+
describe("moonshot registry", () => {
8+
describe("moonshotModels registry invariants", () => {
9+
it("every entry has a positive maxTokens and contextWindow", () => {
10+
for (const [id, info] of modelEntries) {
11+
expect(info.maxTokens).toBeGreaterThan(0)
12+
expect(info.contextWindow).toBeGreaterThan(0)
13+
// Sanity: max output must not exceed the context window.
14+
expect(info.maxTokens).toBeLessThanOrEqual(info.contextWindow)
15+
void id
16+
}
17+
})
18+
19+
it("every entry declares supportsImages and supportsPromptCache", () => {
20+
for (const info of modelInfos) {
21+
expect(typeof info.supportsImages).toBe("boolean")
22+
expect(typeof info.supportsPromptCache).toBe("boolean")
23+
}
24+
})
25+
26+
it("models with an array supportsReasoningEffort expose a non-empty allow-list", () => {
27+
for (const info of modelInfos) {
28+
if (Array.isArray(info.supportsReasoningEffort)) {
29+
expect(info.supportsReasoningEffort.length).toBeGreaterThan(0)
30+
}
31+
}
32+
})
33+
34+
it("every entry declares a reasoningEffort that is covered by its allow-list", () => {
35+
for (const info of modelInfos) {
36+
if (Array.isArray(info.supportsReasoningEffort) && info.reasoningEffort !== undefined) {
37+
expect(info.supportsReasoningEffort).toContain(info.reasoningEffort)
38+
}
39+
}
40+
})
41+
})
42+
43+
describe("kimi-k3", () => {
44+
it("exposes always-on reasoning with effort allow-list and reasoning preservation", () => {
45+
const info = moonshotModels["kimi-k3"]
46+
expect(info).toBeDefined()
47+
expect(info.maxTokens).toBe(131_072)
48+
expect(info.contextWindow).toBe(1_048_576)
49+
expect(info.supportsImages).toBe(true)
50+
expect(info.supportsPromptCache).toBe(true)
51+
expect(info.supportsReasoningEffort).toEqual(["low", "high", "max"])
52+
expect(info.reasoningEffort).toBe("max")
53+
expect(info.preserveReasoning).toBe(true)
54+
expect(info.defaultTemperature).toBe(1.0)
55+
expect(info.inputPrice).toBe(3.0)
56+
expect(info.outputPrice).toBe(15.0)
57+
expect(info.cacheWritesPrice).toBe(0)
58+
expect(info.cacheReadsPrice).toBe(0.3)
59+
})
60+
})
61+
62+
describe("defaults", () => {
63+
it("the default model id is a curated registry entry", () => {
64+
expect(moonshotDefaultModelId).toBe("kimi-k2-0905-preview")
65+
expect(moonshotModels[moonshotDefaultModelId]).toBeDefined()
66+
})
67+
68+
it("exposes a deterministic default temperature", () => {
69+
expect(MOONSHOT_DEFAULT_TEMPERATURE).toBe(0.6)
70+
})
71+
})
72+
})

packages/types/src/__tests__/opencode-go.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe("opencode-go registry", () => {
2121
"glm-5",
2222
"glm-5.1",
2323
"glm-5.2",
24+
"kimi-k3",
2425
"kimi-k2.5",
2526
"kimi-k2.6",
2627
"mimo-v2.5",
@@ -60,6 +61,23 @@ describe("opencode-go registry", () => {
6061
it("returns undefined for an unknown model ID", () => {
6162
expect(getOpencodeGoModelInfo("not-a-real-go-model")).toBeUndefined()
6263
})
64+
65+
it("kimi-k3 exposes always-on reasoning with effort allow-list and reasoning preservation", () => {
66+
const info = getOpencodeGoModelInfo("kimi-k3")
67+
expect(info).toBeDefined()
68+
expect(info?.maxTokens).toBe(131_072)
69+
expect(info?.contextWindow).toBe(1_048_576)
70+
expect(info?.supportsReasoningEffort).toEqual(["low", "high", "max"])
71+
expect(info?.reasoningEffort).toBe("max")
72+
expect(info?.preserveReasoning).toBe(true)
73+
expect(info?.defaultTemperature).toBe(1.0)
74+
expect(info?.supportsPromptCache).toBe(true)
75+
expect(info?.supportsMaxTokens).toBe(true)
76+
expect(info?.supportsImages).toBe(false)
77+
expect(info?.inputPrice).toBe(3.0)
78+
expect(info?.outputPrice).toBe(15.0)
79+
expect(info?.cacheReadsPrice).toBe(0.3)
80+
})
6381
})
6482

6583
describe("OPENCODE_GO_ANTHROPIC_FORMAT_MODELS", () => {

packages/types/src/providers/lite-llm.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export const LITELLM_PRESERVE_REASONING_MODEL_IDS = [
4848
"moonshot.kimi-k2-thinking",
4949
"kimi-k2p7-code",
5050

51+
// moonshot.ts, opencode-go.ts
52+
"kimi-k3",
53+
5154
// zai.ts
5255
"glm-4.7",
5356
"glm-5",

packages/types/src/providers/moonshot.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ export type MoonshotModelId = keyof typeof moonshotModels
66
export const moonshotDefaultModelId: MoonshotModelId = "kimi-k2-0905-preview"
77

88
export const moonshotModels = {
9+
"kimi-k3": {
10+
maxTokens: 131_072, // Default max_completion_tokens (configurable up to 1,048,576)
11+
contextWindow: 1_048_576, // 1M tokens
12+
supportsImages: true, // Native visual understanding (text, image, video)
13+
supportsPromptCache: true, // Automatic context caching
14+
supportsReasoningEffort: ["low", "high", "max"], // Always reasons; default "max"
15+
reasoningEffort: "max",
16+
preserveReasoning: true,
17+
inputPrice: 3.0, // $3.00 per million tokens (cache miss)
18+
outputPrice: 15.0, // $15.00 per million tokens
19+
cacheWritesPrice: 0, // $0 per million tokens (cache miss)
20+
cacheReadsPrice: 0.3, // $0.30 per million tokens (cache hit)
21+
defaultTemperature: 1.0, // temperature is fixed at 1.0
22+
description: `Kimi K3 is Kimi's most capable flagship model with 2.8 trillion parameters, native visual understanding, and a 1M-token context window, designed for long-horizon coding, knowledge work, and deep reasoning. Thinking is always enabled with configurable reasoning effort (low/high/max, default max).`,
23+
},
924
"kimi-k2-0711-preview": {
1025
maxTokens: 32_000,
1126
contextWindow: 131_072,

packages/types/src/providers/opencode-go.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@ export const opencodeGoModels: Record<string, ModelInfo> = {
104104
},
105105

106106
// --- Moonshot Kimi ---
107+
"kimi-k3": {
108+
maxTokens: 131_072, // Default max_completion_tokens (configurable up to 1,048,576)
109+
contextWindow: 1_048_576,
110+
supportsImages: false,
111+
supportsPromptCache: true,
112+
supportsMaxTokens: true,
113+
supportsReasoningEffort: ["low", "high", "max"], // Always reasons; default "max"
114+
reasoningEffort: "max",
115+
preserveReasoning: true,
116+
defaultTemperature: 1.0,
117+
// Go pricing matches Moonshot direct ($3 in / $0.30 cache / $15 out per 1M tokens).
118+
inputPrice: 3.0,
119+
outputPrice: 15.0,
120+
cacheReadsPrice: 0.3,
121+
description:
122+
"Kimi K3 is Moonshot AI's flagship model with 2.8 trillion parameters, a 1M context window, and always-on reasoning with configurable effort (low/high/max). Available via the Opencode Go plan.",
123+
},
107124
"kimi-k2.5": {
108125
maxTokens: 16_384,
109126
contextWindow: 262_144,

0 commit comments

Comments
 (0)