feat(ai): added Kimi K2 models and fixed Claude context window limits

- Added support for Kimi K2, K2 Turbo Preview, and K2.5 models with reasoning capabilities.
- Fixed Claude Opus 4.6 context window to 200K across all providers (was incorrectly set to 1M).
- Fixed Claude Sonnet 4 context window to 200K across multiple providers (was incorrectly set to 1M).
- Improved Kimi Code model fetching to merge fallback models not returned by the API endpoint.
This commit is contained in:
can1357
2026-02-10 16:08:53 +01:00
parent 9ef390c09b
commit 0ca5449f3b
3 changed files with 84 additions and 9 deletions
+8
View File
@@ -1,6 +1,14 @@
# Changelog
## [Unreleased]
### Added
- Added support for Kimi K2, K2 Turbo Preview, and K2.5 models with reasoning capabilities
### Fixed
- Fixed Claude Opus 4.6 context window to 200K across all providers (was incorrectly set to 1M)
- Fixed Claude Sonnet 4 context window to 200K across multiple providers (was incorrectly set to 1M)
## [11.8.0] - 2026-02-10
### Added
+12 -2
View File
@@ -249,7 +249,16 @@ async function fetchKimiCodeModels(): Promise<Model<"openai-completions">[]> {
});
}
console.log(`Fetched ${models.length} models from Kimi Code API`);
// The /models endpoint only returns "kimi-for-coding" but the API
// accepts other model IDs too — merge in fallback models not returned by the API
const fetchedIds = new Set(models.map((m) => m.id));
const fallbacks = getKimiCodeFallbackModels();
for (const fb of fallbacks) {
if (!fetchedIds.has(fb.id)) {
models.push(fb);
}
}
console.log(`Fetched ${fetchedIds.size} models from Kimi Code API, ${models.length} total with fallbacks`);
return models;
} catch (error) {
console.error("Failed to fetch Kimi Code models:", error);
@@ -1065,7 +1074,8 @@ async function generateModels() {
candidate.cost.cacheRead = 0.5;
candidate.cost.cacheWrite = 6.25;
}
if ((candidate.provider === "anthropic" || candidate.provider === "opencode") && candidate.id === "claude-opus-4-6") {
// Opus 4.6 1M context is API-only; all providers should use 200K
if (candidate.id.includes("opus-4-6") || candidate.id.includes("opus-4.6")) {
candidate.contextWindow = 200000;
}
// opencode lists Claude Sonnet 4/4.5 with 1M context, actual limit is 200K
+64 -7
View File
@@ -121,7 +121,7 @@ export const MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 1000000,
contextWindow: 200000,
maxTokens: 128000,
} satisfies Model<"bedrock-converse-stream">,
"cohere.command-r-plus-v1:0": {
@@ -223,7 +223,7 @@ export const MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 1000000,
contextWindow: 200000,
maxTokens: 128000,
} satisfies Model<"bedrock-converse-stream">,
"eu.anthropic.claude-sonnet-4-20250514-v1:0": {
@@ -325,7 +325,7 @@ export const MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 1000000,
contextWindow: 200000,
maxTokens: 128000,
} satisfies Model<"bedrock-converse-stream">,
"global.anthropic.claude-sonnet-4-20250514-v1:0": {
@@ -920,7 +920,7 @@ export const MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 1000000,
contextWindow: 200000,
maxTokens: 128000,
} satisfies Model<"bedrock-converse-stream">,
"us.anthropic.claude-sonnet-4-20250514-v1:0": {
@@ -1801,7 +1801,7 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 128000,
contextWindow: 200000,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
"claude-sonnet-4": {
@@ -3202,6 +3202,63 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 32000,
} satisfies Model<"openai-completions">,
"kimi-k2": {
id: "kimi-k2",
name: "Kimi K2",
api: "openai-completions",
provider: "kimi-code",
baseUrl: "https://api.kimi.com/coding/v1",
headers: {"User-Agent":"KimiCLI/1.0","X-Msh-Platform":"kimi_cli"},
compat: {"thinkingFormat":"zai","reasoningContentField":"reasoning_content","supportsDeveloperRole":false},
reasoning: true,
input: ["text"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 32000,
} satisfies Model<"openai-completions">,
"kimi-k2-turbo-preview": {
id: "kimi-k2-turbo-preview",
name: "Kimi K2 Turbo Preview",
api: "openai-completions",
provider: "kimi-code",
baseUrl: "https://api.kimi.com/coding/v1",
headers: {"User-Agent":"KimiCLI/1.0","X-Msh-Platform":"kimi_cli"},
compat: {"thinkingFormat":"zai","reasoningContentField":"reasoning_content","supportsDeveloperRole":false},
reasoning: true,
input: ["text"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 32000,
} satisfies Model<"openai-completions">,
"kimi-k2.5": {
id: "kimi-k2.5",
name: "Kimi K2.5",
api: "openai-completions",
provider: "kimi-code",
baseUrl: "https://api.kimi.com/coding/v1",
headers: {"User-Agent":"KimiCLI/1.0","X-Msh-Platform":"kimi_cli"},
compat: {"thinkingFormat":"zai","reasoningContentField":"reasoning_content","supportsDeveloperRole":false},
reasoning: true,
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
maxTokens: 32000,
} satisfies Model<"openai-completions">,
},
"minimax": {
"MiniMax-M2": {
@@ -5189,7 +5246,7 @@ export const MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 1000000,
contextWindow: 200000,
maxTokens: 128000,
} satisfies Model<"openai-completions">,
"anthropic/claude-sonnet-4": {
@@ -9189,7 +9246,7 @@ export const MODELS = {
cacheRead: 0.5,
cacheWrite: 6.25,
},
contextWindow: 1000000,
contextWindow: 200000,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
"anthropic/claude-sonnet-4": {