fix(ai): correct Kimi K3 gateway output limits

This commit is contained in:
Armin Ronacher
2026-07-16 18:56:54 +02:00
parent 70c5763297
commit c2c32febb0
4 changed files with 19 additions and 6 deletions
+9
View File
@@ -234,6 +234,8 @@ const KIMI_K3_THINKING_LEVEL_MAP = {
xhigh: null,
max: "max",
} as const;
const KIMI_K3_MAX_TOKENS = 131072;
const OPENROUTER_KIMI_K3_MODEL_IDS = new Set(["moonshotai/kimi-k3", "~moonshotai/kimi-latest"]);
const ANT_LING_RING_THINKING_LEVEL_MAP = {
off: null,
@@ -1825,6 +1827,13 @@ async function generateModels() {
if (candidate.provider === "openai" && candidate.id === "gpt-5-pro") {
candidate.maxTokens = 128000;
}
// Keep Kimi K3's canonical output limit when gateway metadata is missing or incorrect.
if (
(candidate.provider === "openrouter" && OPENROUTER_KIMI_K3_MODEL_IDS.has(candidate.id)) ||
(candidate.provider === "vercel-ai-gateway" && candidate.id === "moonshotai/kimi-k3")
) {
candidate.maxTokens = KIMI_K3_MAX_TOKENS;
}
// Keep selected OpenRouter model metadata stable until upstream settles.
if (candidate.provider === "openrouter" && candidate.id === "moonshotai/kimi-k2.5") {
candidate.cost.input = 0.41;