fix openrouter models: use context length from top provider (#6481)
fixes #6378
This commit is contained in:
@@ -700,6 +700,8 @@ async function fetchOpenRouterModels(): Promise<Model<any>[]> {
|
||||
const cacheReadCost = roundCost(parseFloat(model.pricing?.input_cache_read || "0") * 1_000_000);
|
||||
const cacheWriteCost = roundCost(parseFloat(model.pricing?.input_cache_write || "0") * 1_000_000);
|
||||
|
||||
const contextWindow = model.top_provider?.context_length || model.context_length || 4096;
|
||||
|
||||
const normalizedModel: Model<any> = {
|
||||
id: modelKey,
|
||||
name: model.name,
|
||||
@@ -714,7 +716,7 @@ async function fetchOpenRouterModels(): Promise<Model<any>[]> {
|
||||
cacheRead: cacheReadCost,
|
||||
cacheWrite: cacheWriteCost,
|
||||
},
|
||||
contextWindow: model.context_length || 4096,
|
||||
contextWindow,
|
||||
maxTokens: model.top_provider?.max_completion_tokens || 4096,
|
||||
};
|
||||
models.push(normalizedModel);
|
||||
|
||||
@@ -656,7 +656,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 128000,
|
||||
maxTokens: 16000,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"deepseek/deepseek-chat-v3-0324": {
|
||||
@@ -710,7 +710,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 163840,
|
||||
contextWindow: 64000,
|
||||
maxTokens: 16000,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"deepseek/deepseek-r1-0528": {
|
||||
@@ -759,12 +759,12 @@ export const OPENROUTER_MODELS = {
|
||||
reasoning: true,
|
||||
input: ["text"],
|
||||
cost: {
|
||||
input: 0.2288,
|
||||
output: 0.3432,
|
||||
cacheRead: 0.02288,
|
||||
input: 0.2145,
|
||||
output: 0.32175,
|
||||
cacheRead: 0.02145,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 128000,
|
||||
maxTokens: 64000,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"deepseek/deepseek-v3.2-exp": {
|
||||
@@ -1018,7 +1018,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.2,
|
||||
cacheWrite: 0.375,
|
||||
},
|
||||
contextWindow: 1048756,
|
||||
contextWindow: 1048576,
|
||||
maxTokens: 65536,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"google/gemini-3.5-flash": {
|
||||
@@ -1108,7 +1108,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"google/gemma-4-31b-it": {
|
||||
@@ -1343,7 +1343,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 65536,
|
||||
maxTokens: 4096,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"meta-llama/llama-4-maverick": {
|
||||
@@ -1379,7 +1379,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 10000000,
|
||||
contextWindow: 327680,
|
||||
maxTokens: 16384,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"minimax/minimax-m1": {
|
||||
@@ -1451,7 +1451,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.05,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 204800,
|
||||
contextWindow: 196608,
|
||||
maxTokens: 196608,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"minimax/minimax-m2.7": {
|
||||
@@ -1469,7 +1469,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 204800,
|
||||
contextWindow: 196608,
|
||||
maxTokens: 196608,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"minimax/minimax-m3": {
|
||||
@@ -1487,7 +1487,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.06,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1048576,
|
||||
contextWindow: 1000000,
|
||||
maxTokens: 131072,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"mistralai/codestral-2508": {
|
||||
@@ -1865,7 +1865,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.07,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
contextWindow: 256000,
|
||||
maxTokens: 4096,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"moonshotai/kimi-k2.6": {
|
||||
@@ -2027,7 +2027,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1000000,
|
||||
contextWindow: 262144,
|
||||
maxTokens: 4096,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"nvidia/nemotron-3-super-120b-a12b:free": {
|
||||
@@ -2045,7 +2045,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1000000,
|
||||
contextWindow: 262144,
|
||||
maxTokens: 262144,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"nvidia/nemotron-3-ultra-550b-a55b": {
|
||||
@@ -2063,7 +2063,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.1,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1000000,
|
||||
contextWindow: 262144,
|
||||
maxTokens: 16384,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"nvidia/nemotron-3-ultra-550b-a55b:free": {
|
||||
@@ -3359,7 +3359,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 32768,
|
||||
maxTokens: 16384,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen-2.5-7b-instruct": {
|
||||
@@ -3377,7 +3377,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 32768,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen-plus": {
|
||||
@@ -3449,7 +3449,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131702,
|
||||
contextWindow: 40960,
|
||||
maxTokens: 40960,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-235b-a22b": {
|
||||
@@ -3503,7 +3503,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 4096,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-30b-a3b": {
|
||||
@@ -3521,7 +3521,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 40960,
|
||||
maxTokens: 16384,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-30b-a3b-instruct-2507": {
|
||||
@@ -3539,7 +3539,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 128000,
|
||||
maxTokens: 32000,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-30b-a3b-thinking-2507": {
|
||||
@@ -3557,7 +3557,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 81920,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-32b": {
|
||||
@@ -3575,7 +3575,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 131072,
|
||||
contextWindow: 40960,
|
||||
maxTokens: 16384,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-8b": {
|
||||
@@ -3611,7 +3611,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1048576,
|
||||
contextWindow: 262144,
|
||||
maxTokens: 65536,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-coder-30b-a3b-instruct": {
|
||||
@@ -3701,7 +3701,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1048576,
|
||||
contextWindow: 262000,
|
||||
maxTokens: 262000,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-max": {
|
||||
@@ -3791,7 +3791,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-vl-235b-a22b-instruct": {
|
||||
@@ -3845,7 +3845,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-vl-30b-a3b-thinking": {
|
||||
@@ -3881,7 +3881,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-vl-8b-instruct": {
|
||||
@@ -3899,7 +3899,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 256000,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3-vl-8b-thinking": {
|
||||
@@ -3917,7 +3917,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 256000,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 32768,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3.5-122b-a10b": {
|
||||
@@ -3989,7 +3989,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.111,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 256000,
|
||||
contextWindow: 131072,
|
||||
maxTokens: 4096,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3.5-9b": {
|
||||
@@ -4079,7 +4079,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.15,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 262144,
|
||||
contextWindow: 262140,
|
||||
maxTokens: 262140,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"qwen/qwen3.6-35b-a3b": {
|
||||
@@ -4475,7 +4475,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.028,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1048576,
|
||||
contextWindow: 32000,
|
||||
maxTokens: 4096,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"xiaomi/mimo-v2.5-pro": {
|
||||
@@ -4673,7 +4673,7 @@ export const OPENROUTER_MODELS = {
|
||||
cacheRead: 0.1794,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 202752,
|
||||
contextWindow: 200000,
|
||||
maxTokens: 128000,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"z-ai/glm-5.2": {
|
||||
@@ -4687,13 +4687,13 @@ export const OPENROUTER_MODELS = {
|
||||
thinkingLevelMap: {"xhigh":"xhigh"},
|
||||
input: ["text"],
|
||||
cost: {
|
||||
input: 0.532,
|
||||
output: 1.672,
|
||||
cacheRead: 0.0988,
|
||||
input: 0.92,
|
||||
output: 3,
|
||||
cacheRead: 0.18,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 1048576,
|
||||
maxTokens: 131072,
|
||||
maxTokens: 1048576,
|
||||
} satisfies Model<"openai-completions">,
|
||||
"z-ai/glm-5v-turbo": {
|
||||
id: "z-ai/glm-5v-turbo",
|
||||
|
||||
Reference in New Issue
Block a user