fix(ai): handle OpenCode Kimi reasoning params

This commit is contained in:
Mario Zechner
2026-05-29 23:27:48 +02:00
parent a36a132c70
commit ba2d313858
2 changed files with 77 additions and 54 deletions

View File

@@ -905,6 +905,12 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
compat = { ...(compat ?? {}), supportsReasoningEffort: false }; compat = { ...(compat ?? {}), supportsReasoningEffort: false };
} }
if ((variant.provider === "opencode" || variant.provider === "opencode-go") && modelId === "kimi-k2.6") {
// OpenCode Kimi K2.6 accepts Anthropic-style thinking objects
// and rejects string thinking values or combined reasoning_effort.
compat = { ...(compat ?? {}), thinkingFormat: "deepseek", supportsReasoningEffort: false };
}
// Fix known mismatches between models.dev npm data and actual // Fix known mismatches between models.dev npm data and actual
// OpenCode Go endpoint behaviour. models.dev reports these models // OpenCode Go endpoint behaviour. models.dev reports these models
// as @ai-sdk/anthropic, but the OpenCode Go endpoints either don't // as @ai-sdk/anthropic, but the OpenCode Go endpoints either don't
@@ -917,11 +923,6 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
api = "openai-completions"; api = "openai-completions";
baseUrl = `${variant.basePath}/v1`; baseUrl = `${variant.basePath}/v1`;
} }
if (modelId === "kimi-k2.6") {
// OpenCode Go Kimi K2.6 accepts Anthropic-style thinking objects
// and rejects string thinking values or combined reasoning_effort.
compat = { ...(compat ?? {}), thinkingFormat: "deepseek", supportsReasoningEffort: false };
}
if (modelId === "qwen3.5-plus" || modelId === "qwen3.6-plus") { if (modelId === "qwen3.5-plus" || modelId === "qwen3.6-plus") {
api = "openai-completions"; api = "openai-completions";
baseUrl = `${variant.basePath}/v1`; baseUrl = `${variant.basePath}/v1`;

View File

@@ -3868,8 +3868,8 @@ export const MODELS = {
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 144000, contextWindow: 200000,
maxTokens: 32000, maxTokens: 64000,
} satisfies Model<"anthropic-messages">, } satisfies Model<"anthropic-messages">,
"claude-opus-4.5": { "claude-opus-4.5": {
id: "claude-opus-4.5", id: "claude-opus-4.5",
@@ -3886,7 +3886,7 @@ export const MODELS = {
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 160000, contextWindow: 200000,
maxTokens: 32000, maxTokens: 32000,
} satisfies Model<"anthropic-messages">, } satisfies Model<"anthropic-messages">,
"claude-opus-4.6": { "claude-opus-4.6": {
@@ -3907,7 +3907,7 @@ export const MODELS = {
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 1000000, contextWindow: 1000000,
maxTokens: 64000, maxTokens: 32000,
} satisfies Model<"anthropic-messages">, } satisfies Model<"anthropic-messages">,
"claude-opus-4.7": { "claude-opus-4.7": {
id: "claude-opus-4.7", id: "claude-opus-4.7",
@@ -3926,7 +3926,27 @@ export const MODELS = {
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 144000, contextWindow: 200000,
maxTokens: 32000,
} satisfies Model<"anthropic-messages">,
"claude-opus-4.8": {
id: "claude-opus-4.8",
name: "Claude Opus 4.8",
api: "anthropic-messages",
provider: "github-copilot",
baseUrl: "https://api.individual.githubcopilot.com",
headers: {"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},
compat: {"forceAdaptiveThinking":true},
reasoning: true,
thinkingLevelMap: {"xhigh":"xhigh"},
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 200000,
maxTokens: 64000, maxTokens: 64000,
} satisfies Model<"anthropic-messages">, } satisfies Model<"anthropic-messages">,
"claude-sonnet-4.5": { "claude-sonnet-4.5": {
@@ -3945,7 +3965,7 @@ export const MODELS = {
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 144000, contextWindow: 200000,
maxTokens: 32000, maxTokens: 32000,
} satisfies Model<"anthropic-messages">, } satisfies Model<"anthropic-messages">,
"claude-sonnet-4.6": { "claude-sonnet-4.6": {
@@ -4021,7 +4041,7 @@ export const MODELS = {
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 128000, contextWindow: 200000,
maxTokens: 64000, maxTokens: 64000,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"gemini-3.5-flash": { "gemini-3.5-flash": {
@@ -4040,7 +4060,7 @@ export const MODELS = {
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 128000, contextWindow: 200000,
maxTokens: 64000, maxTokens: 64000,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"gpt-4.1": { "gpt-4.1": {
@@ -4116,8 +4136,8 @@ export const MODELS = {
cacheRead: 0, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 264000, contextWindow: 400000,
maxTokens: 64000, maxTokens: 128000,
} satisfies Model<"openai-responses">, } satisfies Model<"openai-responses">,
"gpt-5.2-codex": { "gpt-5.2-codex": {
id: "gpt-5.2-codex", id: "gpt-5.2-codex",
@@ -7724,7 +7744,9 @@ export const MODELS = {
api: "openai-completions", api: "openai-completions",
provider: "opencode", provider: "opencode",
baseUrl: "https://opencode.ai/zen/v1", baseUrl: "https://opencode.ai/zen/v1",
compat: {"supportsReasoningEffort":false},
reasoning: true, reasoning: true,
thinkingLevelMap: {"off":null,"minimal":null,"low":null,"medium":null},
input: ["text", "image"], input: ["text", "image"],
cost: { cost: {
input: 1, input: 1,
@@ -7758,6 +7780,7 @@ export const MODELS = {
api: "openai-completions", api: "openai-completions",
provider: "opencode", provider: "opencode",
baseUrl: "https://opencode.ai/zen/v1", baseUrl: "https://opencode.ai/zen/v1",
compat: {"thinkingFormat":"deepseek","supportsReasoningEffort":false},
reasoning: true, reasoning: true,
input: ["text", "image"], input: ["text", "image"],
cost: { cost: {
@@ -7968,9 +7991,9 @@ export const MODELS = {
api: "openai-completions", api: "openai-completions",
provider: "opencode-go", provider: "opencode-go",
baseUrl: "https://opencode.ai/zen/go/v1", baseUrl: "https://opencode.ai/zen/go/v1",
compat: {"thinkingFormat":"string-thinking"}, compat: {"thinkingFormat":"deepseek","supportsReasoningEffort":false},
reasoning: true, reasoning: true,
thinkingLevelMap: {"off":"none"}, thinkingLevelMap: {"minimal":null,"low":null,"medium":null},
input: ["text", "image"], input: ["text", "image"],
cost: { cost: {
input: 0.95, input: 0.95,
@@ -8049,24 +8072,6 @@ export const MODELS = {
contextWindow: 204800, contextWindow: 204800,
maxTokens: 131072, maxTokens: 131072,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"qwen3.5-plus": {
id: "qwen3.5-plus",
name: "Qwen3.5 Plus",
api: "openai-completions",
provider: "opencode-go",
baseUrl: "https://opencode.ai/zen/go/v1",
compat: {"thinkingFormat":"qwen"},
reasoning: true,
input: ["text", "image"],
cost: {
input: 0.2,
output: 1.2,
cacheRead: 0.02,
cacheWrite: 0.25,
},
contextWindow: 262144,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen3.6-plus": { "qwen3.6-plus": {
id: "qwen3.6-plus", id: "qwen3.6-plus",
name: "Qwen3.6 Plus", name: "Qwen3.6 Plus",
@@ -8818,13 +8823,13 @@ export const MODELS = {
thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","xhigh":"xhigh"}, thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","xhigh":"xhigh"},
input: ["text"], input: ["text"],
cost: { cost: {
input: 0.09999999999999999, input: 0.0983,
output: 0.19999999999999998, output: 0.1966,
cacheRead: 0.02, cacheRead: 0.019700000000000002,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 1048576, contextWindow: 1048576,
maxTokens: 16384, maxTokens: 131072,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"deepseek/deepseek-v4-flash:free": { "deepseek/deepseek-v4-flash:free": {
id: "deepseek/deepseek-v4-flash:free", id: "deepseek/deepseek-v4-flash:free",
@@ -8895,7 +8900,7 @@ export const MODELS = {
cacheRead: 0.024999999999999998, cacheRead: 0.024999999999999998,
cacheWrite: 0.08333333333333334, cacheWrite: 0.08333333333333334,
}, },
contextWindow: 1000000, contextWindow: 1048576,
maxTokens: 8192, maxTokens: 8192,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"google/gemini-2.0-flash-lite-001": { "google/gemini-2.0-flash-lite-001": {
@@ -9945,13 +9950,13 @@ export const MODELS = {
reasoning: true, reasoning: true,
input: ["text", "image"], input: ["text", "image"],
cost: { cost: {
input: 0.73, input: 0.684,
output: 3.49, output: 3.42,
cacheRead: 0.25, cacheRead: 0.144,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 262144, contextWindow: 262144,
maxTokens: 262142, maxTokens: 262144,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"moonshotai/kimi-k2.6:free": { "moonshotai/kimi-k2.6:free": {
id: "moonshotai/kimi-k2.6:free", id: "moonshotai/kimi-k2.6:free",
@@ -12090,6 +12095,23 @@ export const MODELS = {
contextWindow: 262144, contextWindow: 262144,
maxTokens: 16384, maxTokens: 16384,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"stepfun/step-3.7-flash": {
id: "stepfun/step-3.7-flash",
name: "StepFun: Step 3.7 Flash",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
reasoning: true,
input: ["text", "image"],
cost: {
input: 0.19999999999999998,
output: 1.15,
cacheRead: 0.04,
cacheWrite: 0,
},
contextWindow: 256000,
maxTokens: 256000,
} satisfies Model<"openai-completions">,
"tencent/hy3-preview": { "tencent/hy3-preview": {
id: "tencent/hy3-preview", id: "tencent/hy3-preview",
name: "Tencent: Hy3 preview", name: "Tencent: Hy3 preview",
@@ -12609,13 +12631,13 @@ export const MODELS = {
reasoning: true, reasoning: true,
input: ["text", "image"], input: ["text", "image"],
cost: { cost: {
input: 0.73, input: 0.684,
output: 3.49, output: 3.42,
cacheRead: 0.25, cacheRead: 0.144,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 262144, contextWindow: 262144,
maxTokens: 262142, maxTokens: 262144,
} satisfies Model<"openai-completions">, } satisfies Model<"openai-completions">,
"~openai/gpt-latest": { "~openai/gpt-latest": {
id: "~openai/gpt-latest", id: "~openai/gpt-latest",
@@ -13013,20 +13035,20 @@ export const MODELS = {
} satisfies Model<"anthropic-messages">, } satisfies Model<"anthropic-messages">,
"alibaba/qwen-3-235b": { "alibaba/qwen-3-235b": {
id: "alibaba/qwen-3-235b", id: "alibaba/qwen-3-235b",
name: "Qwen3 235B A22b Instruct 2507", name: "Qwen3 235B A22B",
api: "anthropic-messages", api: "anthropic-messages",
provider: "vercel-ai-gateway", provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh", baseUrl: "https://ai-gateway.vercel.sh",
reasoning: false, reasoning: false,
input: ["text"], input: ["text"],
cost: { cost: {
input: 0.6, input: 0.22,
output: 1.2, output: 0.88,
cacheRead: 0.6, cacheRead: 0,
cacheWrite: 0, cacheWrite: 0,
}, },
contextWindow: 131000, contextWindow: 262144,
maxTokens: 40000, maxTokens: 16384,
} satisfies Model<"anthropic-messages">, } satisfies Model<"anthropic-messages">,
"alibaba/qwen-3-30b": { "alibaba/qwen-3-30b": {
id: "alibaba/qwen-3-30b", id: "alibaba/qwen-3-30b",