Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix team-gated prime inference models (#421)

ktfcbfd5783a24
diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md
index 6f5b57c365..3ba6bffab6 100644
--- a/packages/ai/CHANGELOG.md
+++ b/packages/ai/CHANGELOG.md
@@ -2,6 +2,8 @@
## [Unreleased]
+- Removed team-gated internal Prime Inference routes from the public model catalog so clients can discover them from authenticated team catalogs instead.
+
## [0.3.0] - 2026-07-13
## [0.2.9] - 2026-07-13
diff --git a/packages/ai/scripts/generate-models.ts b/packages/ai/scripts/generate-models.ts
index 9ec7676163..a133fed36f 100644
--- a/packages/ai/scripts/generate-models.ts
+++ b/packages/ai/scripts/generate-models.ts
@@ -135,7 +135,6 @@ const PRIME_INFERENCE_MODEL_METADATA: Record<string, PrimeInferenceModelMetadata
// prompt (opus-4.7/4.8, sonnet-4.6/5, fable-5 verified individually).
"anthropic/claude-sonnet-4": { contextWindow: 200000 },
"anthropic/claude-sonnet-4.5": { contextWindow: 200000 },
- "internal/glm-5.2-fast": { name: "GLM 5.2 Fast" },
// Enforced windows measured against the live gateway 2026-07-08 where they
// are SMALLER than OpenRouter's listing — over-declaring breaks context
// tracking. (Measured by binary-searching the max_tokens reject boundary.)
@@ -174,7 +173,6 @@ const PRIME_INFERENCE_FEATURED_MODELS = new Set([
"deepseek/deepseek-v3.2",
"deepseek/deepseek-v4-flash",
"deepseek/deepseek-v4-pro",
- "internal/glm-5.2-fast",
"minimax/minimax-m3",
"moonshotai/kimi-k2.7-code",
"nvidia/nemotron-3-nano-30b-a3b",
@@ -195,10 +193,8 @@ const PRIME_INFERENCE_FEATURED_MODELS = new Set([
"z-ai/glm-5.2",
]);
-// Prime ids whose OpenRouter listing uses a different id. internal/glm-5.2-fast
-// serves the same underlying model as z-ai/glm-5.2, so it borrows its metadata.
+// Prime ids whose OpenRouter listing uses a different id.
const PRIME_INFERENCE_OPENROUTER_ALIASES: Record<string, string> = {
- "internal/glm-5.2-fast": "z-ai/glm-5.2",
"nvidia/nvidia-nemotron-3-ultra-550b-a55b": "nvidia/nemotron-3-ultra-550b-a55b",
};
@@ -219,6 +215,10 @@ function isPrimeInferenceRawVariant(modelId: string): boolean {
return vendor === "zai-org" || vendor !== vendor.toLowerCase();
}
+function isPrimeInferencePrivateModel(modelId: string): boolean {
+ return modelId.toLowerCase().startsWith("internal/");
+}
+
const OPENAI_RESPONSES_NONE_REASONING_MODELS = new Set([
"gpt-5.1",
"gpt-5.2",
@@ -403,7 +403,7 @@ function getPrimeInferenceHeaders(apiKey: string | undefined, teamId: string | u
function getExistingPrimeInferenceModels(): Model<"openai-completions">[] {
const models = EXISTING_MODELS["prime-inference"] as unknown as Record<string, Model<"openai-completions">>;
return Object.values(models)
- .filter((model) => !isPrimeInferenceRawVariant(model.id))
+ .filter((model) => !isPrimeInferenceRawVariant(model.id) && !isPrimeInferencePrivateModel(model.id))
.map((model) => ({
...model,
input: [...model.input],
@@ -506,7 +506,6 @@ function isPrimeInferenceReasoningModel(modelId: string, catalogReasoning?: bool
return (
id.includes("thinking") ||
id.includes("deepseek-v4") ||
- id.startsWith("internal/glm-") ||
id.startsWith("minimax/minimax-m") ||
id.startsWith("moonshotai/kimi") ||
id.startsWith("x-ai/grok-4") ||
@@ -524,7 +523,7 @@ function getPrimeInferenceCompat(modelId: string): OpenAICompletionsCompat {
...DEEPSEEK_V4_COMPAT,
};
}
- if (id.startsWith("z-ai/glm-") || id.startsWith("internal/glm-")) {
+ if (id.startsWith("z-ai/glm-")) {
return {
...PRIME_INFERENCE_COMPAT,
...ZAI_THINKING_COMPAT,
@@ -633,7 +632,7 @@ async function fetchPrimeInferenceModels(): Promise<Model<"openai-completions">[
}
const catalogModels = catalog
- .filter((entry) => !isPrimeInferenceRawVariant(entry.id))
+ .filter((entry) => !isPrimeInferenceRawVariant(entry.id) && !isPrimeInferencePrivateModel(entry.id))
.map((entry) =>
createPrimeInferenceModel(
entry,
@@ -643,15 +642,8 @@ async function fetchPrimeInferenceModels(): Promise<Model<"openai-completions">[
);
let snapshotModels = getExistingPrimeInferenceModels();
if (catalog.length > 0) {
- // A successful fetch is authoritative for public routes, so delisted
- // models drop out automatically. Snapshot-only entries survive just for
- // the team-gated internal/ namespace, which vanishes from the catalog
- // when the fetch runs without team credentials. (Retiring an internal
- // route therefore requires pruning it from models.generated.ts by hand.)
- const liveIds = new Set(catalog.map((entry) => entry.id.toLowerCase()));
- snapshotModels = snapshotModels.filter(
- (model) => liveIds.has(model.id.toLowerCase()) || model.id.toLowerCase().startsWith("internal/"),
- );
+ const liveIds = new Set(catalogModels.map((model) => model.id.toLowerCase()));
+ snapshotModels = snapshotModels.filter((model) => liveIds.has(model.id.toLowerCase()));
}
snapshotModels = refreshPrimeInferenceAliasLimits(snapshotModels, catalogModels);
const models = mergePrimeInferenceModels(snapshotModels, catalogModels);
diff --git a/packages/ai/src/models.generated.ts b/packages/ai/src/models.generated.ts
index 62cdd3126d..6686fd59a1 100644
--- a/packages/ai/src/models.generated.ts
+++ b/packages/ai/src/models.generated.ts
@@ -1291,6 +1291,60 @@ export const MODELS = {
contextWindow: 272000,
maxTokens: 128000,
} satisfies Model<"bedrock-converse-stream">,
+ "openai.gpt-5.6-luna": {
+ id: "openai.gpt-5.6-luna",
+ name: "GPT-5.6 Luna",
+ api: "bedrock-converse-stream",
+ provider: "amazon-bedrock",
+ baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 1,
+ output: 6,
+ cacheRead: 0.1,
+ cacheWrite: 1.25,
+ },
+ contextWindow: 272000,
+ maxTokens: 128000,
+ } satisfies Model<"bedrock-converse-stream">,
+ "openai.gpt-5.6-sol": {
+ id: "openai.gpt-5.6-sol",
+ name: "GPT-5.6 Sol",
+ api: "bedrock-converse-stream",
+ provider: "amazon-bedrock",
+ baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0.5,
+ cacheWrite: 6.25,
+ },
+ contextWindow: 272000,
+ maxTokens: 128000,
+ } satisfies Model<"bedrock-converse-stream">,
+ "openai.gpt-5.6-terra": {
+ id: "openai.gpt-5.6-terra",
+ name: "GPT-5.6 Terra",
+ api: "bedrock-converse-stream",
+ provider: "amazon-bedrock",
+ baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 2.5,
+ output: 15,
+ cacheRead: 0.25,
+ cacheWrite: 3.125,
+ },
+ contextWindow: 272000,
+ maxTokens: 128000,
+ } satisfies Model<"bedrock-converse-stream">,
"openai.gpt-oss-120b": {
id: "openai.gpt-oss-120b",
name: "gpt-oss-120b",
@@ -2763,6 +2817,23 @@ export const MODELS = {
contextWindow: 1050000,
maxTokens: 128000,
} satisfies Model<"azure-openai-responses">,
+ "gpt-realtime-2.1": {
+ id: "gpt-realtime-2.1",
+ name: "GPT-Realtime-2.1",
+ api: "azure-openai-responses",
+ provider: "azure-openai-responses",
+ baseUrl: "",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 4,
+ output: 24,
+ cacheRead: 0.4,
+ cacheWrite: 0,
+ },
+ contextWindow: 128000,
+ maxTokens: 32000,
+ } satisfies Model<"azure-openai-responses">,
"o1": {
id: "o1",
name: "o1",
@@ -2946,7 +3017,7 @@ export const MODELS = {
cost: {
input: 2.25,
output: 2.75,
- cacheRead: 0,
+ cacheRead: 2.25,
cacheWrite: 0,
},
contextWindow: 131072,
@@ -3460,6 +3531,60 @@ export const MODELS = {
contextWindow: 1050000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
+ "gpt-5.6-luna": {
+ id: "gpt-5.6-luna",
+ name: "GPT-5.6 Luna",
+ api: "openai-responses",
+ provider: "cloudflare-ai-gateway",
+ baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 1,
+ output: 6,
+ cacheRead: 0.1,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "gpt-5.6-sol": {
+ id: "gpt-5.6-sol",
+ name: "GPT-5.6 Sol",
+ api: "openai-responses",
+ provider: "cloudflare-ai-gateway",
+ baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0.5,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "gpt-5.6-terra": {
+ id: "gpt-5.6-terra",
+ name: "GPT-5.6 Terra",
+ api: "openai-responses",
+ provider: "cloudflare-ai-gateway",
+ baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai",
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 2.5,
+ output: 15,
+ cacheRead: 0.25,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
"o1": {
id: "o1",
name: "o1",
@@ -3617,6 +3742,24 @@ export const MODELS = {
contextWindow: 131072,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
+ "workers-ai/@cf/zai-org/glm-5.2": {
+ id: "workers-ai/@cf/zai-org/glm-5.2",
+ name: "Glm 5.2",
+ api: "openai-completions",
+ provider: "cloudflare-ai-gateway",
+ baseUrl: "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/compat",
+ compat: {"sendSessionAffinityHeaders":true},
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 1.4,
+ output: 4.4,
+ cacheRead: 0.26,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 262144,
+ } satisfies Model<"openai-completions">,
},
"cloudflare-workers-ai": {
"@cf/google/gemma-4-26b-a4b-it": {
@@ -4414,7 +4557,7 @@ export const MODELS = {
cacheRead: 0.2,
cacheWrite: 0,
},
- contextWindow: 200000,
+ contextWindow: 1000000,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
"gemini-3.5-flash": {
@@ -4547,7 +4690,7 @@ export const MODELS = {
cacheRead: 0.25,
cacheWrite: 0,
},
- contextWindow: 400000,
+ contextWindow: 1050000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
"gpt-5.4-mini": {
@@ -4604,7 +4747,64 @@ export const MODELS = {
cacheRead: 0.5,
cacheWrite: 0,
},
- contextWindow: 400000,
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "gpt-5.6-luna": {
+ id: "gpt-5.6-luna",
+ name: "GPT-5.6 Luna",
+ api: "openai-responses",
+ 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"},
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 1,
+ output: 6,
+ cacheRead: 0.1,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "gpt-5.6-sol": {
+ id: "gpt-5.6-sol",
+ name: "GPT-5.6 Sol",
+ api: "openai-responses",
+ 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"},
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0.5,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "gpt-5.6-terra": {
+ id: "gpt-5.6-terra",
+ name: "GPT-5.6 Terra",
+ api: "openai-responses",
+ 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"},
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 2.5,
+ output: 15,
+ cacheRead: 0.25,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
"kimi-k2.7-code": {
@@ -4867,9 +5067,9 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.3,
- output: 2.5,
- cacheRead: 0.075,
+ input: 1.5,
+ output: 9,
+ cacheRead: 0.15,
cacheWrite: 0,
},
contextWindow: 1048576,
@@ -4884,8 +5084,8 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.1,
- output: 0.4,
+ input: 0.25,
+ output: 1.5,
cacheRead: 0.025,
cacheWrite: 0,
},
@@ -6199,6 +6399,24 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 32768,
} satisfies Model<"anthropic-messages">,
+ "kimi-for-coding-highspeed": {
+ id: "kimi-for-coding-highspeed",
+ name: "Kimi For Coding HighSpeed",
+ api: "anthropic-messages",
+ provider: "kimi-coding",
+ baseUrl: "https://api.kimi.com/coding",
+ headers: {"User-Agent":"KimiCLI/1.5"},
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 0,
+ output: 0,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 262144,
+ maxTokens: 32768,
+ } satisfies Model<"anthropic-messages">,
"kimi-k2-thinking": {
id: "kimi-k2-thinking",
name: "Kimi K2 Thinking",
@@ -7805,6 +8023,23 @@ export const MODELS = {
contextWindow: 1050000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
+ "gpt-realtime-2.1": {
+ id: "gpt-realtime-2.1",
+ name: "GPT-Realtime-2.1",
+ api: "openai-responses",
+ provider: "openai",
+ baseUrl: "https://api.openai.com/v1",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 4,
+ output: 24,
+ cacheRead: 0.4,
+ cacheWrite: 0,
+ },
+ contextWindow: 128000,
+ maxTokens: 32000,
+ } satisfies Model<"openai-responses">,
"o1": {
id: "o1",
name: "o1",
@@ -8837,32 +9072,86 @@ export const MODELS = {
contextWindow: 1050000,
maxTokens: 128000,
} satisfies Model<"openai-responses">,
- "grok-4.5": {
- id: "grok-4.5",
- name: "Grok 4.5",
- api: "openai-completions",
+ "gpt-5.6-luna": {
+ id: "gpt-5.6-luna",
+ name: "GPT-5.6 Luna",
+ api: "openai-responses",
provider: "opencode",
baseUrl: "https://opencode.ai/zen/v1",
reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
input: ["text", "image"],
cost: {
- input: 2,
+ input: 1,
output: 6,
- cacheRead: 0.5,
- cacheWrite: 0,
+ cacheRead: 0.1,
+ cacheWrite: 1.25,
},
- contextWindow: 500000,
- maxTokens: 500000,
- } satisfies Model<"openai-completions">,
- "grok-build-0.1": {
- id: "grok-build-0.1",
- name: "Grok Build 0.1",
- api: "openai-completions",
- provider: "opencode",
- baseUrl: "https://opencode.ai/zen/v1",
- reasoning: true,
- input: ["text", "image"],
- cost: {
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "gpt-5.6-sol": {
+ id: "gpt-5.6-sol",
+ name: "GPT-5.6 Sol",
+ api: "openai-responses",
+ provider: "opencode",
+ baseUrl: "https://opencode.ai/zen/v1",
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0.5,
+ cacheWrite: 6.25,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "gpt-5.6-terra": {
+ id: "gpt-5.6-terra",
+ name: "GPT-5.6 Terra",
+ api: "openai-responses",
+ provider: "opencode",
+ baseUrl: "https://opencode.ai/zen/v1",
+ reasoning: true,
+ thinkingLevelMap: {"off":null,"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 2.5,
+ output: 15,
+ cacheRead: 0.25,
+ cacheWrite: 3.125,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-responses">,
+ "grok-4.5": {
+ id: "grok-4.5",
+ name: "Grok 4.5",
+ api: "openai-completions",
+ provider: "opencode",
+ baseUrl: "https://opencode.ai/zen/v1",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 2,
+ output: 6,
+ cacheRead: 0.5,
+ cacheWrite: 0,
+ },
+ contextWindow: 500000,
+ maxTokens: 500000,
+ } satisfies Model<"openai-completions">,
+ "grok-build-0.1": {
+ id: "grok-build-0.1",
+ name: "Grok Build 0.1",
+ api: "openai-completions",
+ provider: "opencode",
+ baseUrl: "https://opencode.ai/zen/v1",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
input: 1,
output: 2,
cacheRead: 0.2,
@@ -8885,7 +9174,7 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 256000,
+ contextWindow: 190000,
maxTokens: 64000,
} satisfies Model<"openai-completions">,
"kimi-k2.5": {
@@ -9738,23 +10027,6 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 80000,
} satisfies Model<"openai-completions">,
- "arcee-ai/trinity-mini": {
- id: "arcee-ai/trinity-mini",
- name: "Arcee AI: Trinity Mini",
- api: "openai-completions",
- provider: "openrouter",
- baseUrl: "https://openrouter.ai/api/v1",
- reasoning: true,
- input: ["text"],
- cost: {
- input: 0.045,
- output: 0.15,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 131072,
- maxTokens: 131072,
- } satisfies Model<"openai-completions">,
"arcee-ai/virtuoso-large": {
id: "arcee-ai/virtuoso-large",
name: "Arcee AI: Virtuoso Large",
@@ -9934,13 +10206,13 @@ export const MODELS = {
reasoning: false,
input: ["text"],
cost: {
- input: 0.24,
- output: 0.8999999999999999,
+ input: 0.27,
+ output: 1.12,
cacheRead: 0.135,
cacheWrite: 0,
},
contextWindow: 163840,
- maxTokens: 16384,
+ maxTokens: 65536,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-chat-v3.1": {
id: "deepseek/deepseek-chat-v3.1",
@@ -9951,8 +10223,8 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.21,
- output: 0.7899999999999999,
+ input: 0.25,
+ output: 0.95,
cacheRead: 0.13,
cacheWrite: 0,
},
@@ -10003,11 +10275,11 @@ export const MODELS = {
input: ["text"],
cost: {
input: 0.27,
- output: 0.95,
- cacheRead: 0.13,
+ output: 1,
+ cacheRead: 0.135,
cacheWrite: 0,
},
- contextWindow: 163840,
+ contextWindow: 131072,
maxTokens: 32768,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-v3.2": {
@@ -10019,13 +10291,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.2288,
- output: 0.3432,
- cacheRead: 0.02288,
+ input: 0.26899999999999996,
+ output: 0.39999999999999997,
+ cacheRead: 0.13449999999999998,
cacheWrite: 0,
},
- contextWindow: 131072,
- maxTokens: 64000,
+ contextWindow: 163840,
+ maxTokens: 65536,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-v3.2-exp": {
id: "deepseek/deepseek-v3.2-exp",
@@ -10055,13 +10327,13 @@ export const MODELS = {
thinkingLevelMap: {"minimal":null,"low":null,"medium":null,"high":"high","xhigh":"max"},
input: ["text"],
cost: {
- input: 0.09,
- output: 0.18,
- cacheRead: 0.018,
+ input: 0.098,
+ output: 0.196,
+ cacheRead: 0.02,
cacheWrite: 0,
},
contextWindow: 1048576,
- maxTokens: 65536,
+ maxTokens: 4096,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-v4-pro": {
id: "deepseek/deepseek-v4-pro",
@@ -10313,12 +10585,12 @@ export const MODELS = {
input: ["text", "image"],
cost: {
input: 0.08,
- output: 0.16,
- cacheRead: 0,
+ output: 0.44999999999999996,
+ cacheRead: 0.04,
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 16384,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"google/gemma-4-26b-a4b-it": {
id: "google/gemma-4-26b-a4b-it",
@@ -10329,13 +10601,13 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.06,
- output: 0.33,
+ input: 0.09999999999999999,
+ output: 0.3,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 4096,
+ maxTokens: 256000,
} satisfies Model<"openai-completions">,
"google/gemma-4-26b-a4b-it:free": {
id: "google/gemma-4-26b-a4b-it:free",
@@ -10363,9 +10635,9 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.12,
- output: 0.35,
- cacheRead: 0.09,
+ input: 0.22,
+ output: 0.55,
+ cacheRead: 0.12,
cacheWrite: 0,
},
contextWindow: 262144,
@@ -10386,7 +10658,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 8192,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
"ibm-granite/granite-4.1-8b": {
id: "ibm-granite/granite-4.1-8b",
@@ -10473,6 +10745,23 @@ export const MODELS = {
contextWindow: 262144,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
+ "kwaipilot/kat-coder-air-v2.5": {
+ id: "kwaipilot/kat-coder-air-v2.5",
+ name: "Kwaipilot: KAT-Coder-Air V2.5",
+ api: "openai-completions",
+ provider: "openrouter",
+ baseUrl: "https://openrouter.ai/api/v1",
+ reasoning: false,
+ input: ["text"],
+ cost: {
+ input: 0.15,
+ output: 0.6,
+ cacheRead: 0.03,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 80000,
+ } satisfies Model<"openai-completions">,
"kwaipilot/kat-coder-pro-v2": {
id: "kwaipilot/kat-coder-pro-v2",
name: "Kwaipilot: KAT-Coder-Pro V2",
@@ -10490,22 +10779,22 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 80000,
} satisfies Model<"openai-completions">,
- "liquid/lfm-2.5-1.2b-thinking:free": {
- id: "liquid/lfm-2.5-1.2b-thinking:free",
- name: "LiquidAI: LFM2.5-1.2B-Thinking (free)",
+ "kwaipilot/kat-coder-pro-v2.5": {
+ id: "kwaipilot/kat-coder-pro-v2.5",
+ name: "Kwaipilot: KAT-Coder-Pro V2.5",
api: "openai-completions",
provider: "openrouter",
baseUrl: "https://openrouter.ai/api/v1",
- reasoning: true,
+ reasoning: false,
input: ["text"],
cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
+ input: 0.74,
+ output: 2.96,
+ cacheRead: 0.15,
cacheWrite: 0,
},
- contextWindow: 32768,
- maxTokens: 4096,
+ contextWindow: 256000,
+ maxTokens: 80000,
} satisfies Model<"openai-completions">,
"meta-llama/llama-3.1-70b-instruct": {
id: "meta-llama/llama-3.1-70b-instruct",
@@ -10533,13 +10822,13 @@ export const MODELS = {
reasoning: false,
input: ["text"],
cost: {
- input: 0.02,
- output: 0.03,
- cacheRead: 0,
+ input: 0.049999999999999996,
+ output: 0.08,
+ cacheRead: 0.024999999999999998,
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 16384,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"meta-llama/llama-3.3-70b-instruct": {
id: "meta-llama/llama-3.3-70b-instruct",
@@ -10550,13 +10839,13 @@ export const MODELS = {
reasoning: false,
input: ["text"],
cost: {
- input: 0.09999999999999999,
- output: 0.32,
+ input: 0.13,
+ output: 0.39999999999999997,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 16384,
+ maxTokens: 128000,
} satisfies Model<"openai-completions">,
"meta-llama/llama-3.3-70b-instruct:free": {
id: "meta-llama/llama-3.3-70b-instruct:free",
@@ -10584,8 +10873,8 @@ export const MODELS = {
reasoning: false,
input: ["text", "image"],
cost: {
- input: 0.15,
- output: 0.6,
+ input: 0.19999999999999998,
+ output: 0.7999999999999999,
cacheRead: 0,
cacheWrite: 0,
},
@@ -10618,7 +10907,7 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.39999999999999997,
+ input: 0.55,
output: 2.2,
cacheRead: 0,
cacheWrite: 0,
@@ -10686,13 +10975,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.24,
- output: 0.96,
- cacheRead: 0,
+ input: 0.3,
+ output: 1.2,
+ cacheRead: 0.06,
cacheWrite: 0,
},
contextWindow: 204800,
- maxTokens: 196608,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"minimax/minimax-m3": {
id: "minimax/minimax-m3",
@@ -10908,12 +11197,12 @@ export const MODELS = {
input: ["text"],
cost: {
input: 0.02,
- output: 0.03,
+ output: 0.04,
cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 4096,
+ maxTokens: 16384,
} satisfies Model<"openai-completions">,
"mistralai/mistral-saba": {
id: "mistralai/mistral-saba",
@@ -10958,13 +11247,13 @@ export const MODELS = {
reasoning: false,
input: ["text", "image"],
cost: {
- input: 0.075,
- output: 0.19999999999999998,
- cacheRead: 0,
+ input: 0.09999999999999999,
+ output: 0.3,
+ cacheRead: 0.01,
cacheWrite: 0,
},
- contextWindow: 128000,
- maxTokens: 16384,
+ contextWindow: 131072,
+ maxTokens: 4096,
} satisfies Model<"openai-completions">,
"mistralai/mixtral-8x22b-instruct": {
id: "mistralai/mixtral-8x22b-instruct",
@@ -11045,11 +11334,11 @@ export const MODELS = {
cost: {
input: 0.6,
output: 2.5,
- cacheRead: 0.15,
+ cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 100352,
+ maxTokens: 262144,
} satisfies Model<"openai-completions">,
"moonshotai/kimi-k2.5": {
id: "moonshotai/kimi-k2.5",
@@ -11077,9 +11366,9 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.65,
+ input: 0.66,
output: 3.41,
- cacheRead: 0.14,
+ cacheRead: 0.144,
cacheWrite: 0,
},
contextWindow: 262144,
@@ -11094,9 +11383,9 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.72,
+ input: 0.719,
output: 3.49,
- cacheRead: 0.159,
+ cacheRead: 0.149,
cacheWrite: 0,
},
contextWindow: 262144,
@@ -11213,9 +11502,9 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.08,
- output: 0.44999999999999996,
- cacheRead: 0,
+ input: 0.21,
+ output: 0.45499999999999996,
+ cacheRead: 0.06,
cacheWrite: 0,
},
contextWindow: 1000000,
@@ -11247,13 +11536,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.5,
- output: 2.2,
- cacheRead: 0.09999999999999999,
+ input: 0.6,
+ output: 3.5999999999999996,
+ cacheRead: 0.19999999999999998,
cacheWrite: 0,
},
contextWindow: 1000000,
- maxTokens: 16384,
+ maxTokens: 4096,
} satisfies Model<"openai-completions">,
"nvidia/nemotron-3-ultra-550b-a55b:free": {
id: "nvidia/nemotron-3-ultra-550b-a55b:free",
@@ -11423,7 +11712,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 1047576,
- maxTokens: 4096,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
"openai/gpt-4.1-mini": {
id: "openai/gpt-4.1-mini",
@@ -11470,7 +11759,7 @@ export const MODELS = {
cost: {
input: 2.5,
output: 10,
- cacheRead: 0,
+ cacheRead: 1.25,
cacheWrite: 0,
},
contextWindow: 128000,
@@ -11623,11 +11912,11 @@ export const MODELS = {
cost: {
input: 0.049999999999999996,
output: 0.39999999999999997,
- cacheRead: 0.01,
+ cacheRead: 0.005,
cacheWrite: 0,
},
contextWindow: 400000,
- maxTokens: 4096,
+ maxTokens: 128000,
} satisfies Model<"openai-completions">,
"openai/gpt-5-pro": {
id: "openai/gpt-5-pro",
@@ -11657,7 +11946,7 @@ export const MODELS = {
cost: {
input: 1.25,
output: 10,
- cacheRead: 0.13,
+ cacheRead: 0.125,
cacheWrite: 0,
},
contextWindow: 400000,
@@ -11674,11 +11963,11 @@ export const MODELS = {
cost: {
input: 1.25,
output: 10,
- cacheRead: 0.13,
+ cacheRead: 0.125,
cacheWrite: 0,
},
contextWindow: 128000,
- maxTokens: 32000,
+ maxTokens: 16384,
} satisfies Model<"openai-completions">,
"openai/gpt-5.1-codex": {
id: "openai/gpt-5.1-codex",
@@ -11691,7 +11980,7 @@ export const MODELS = {
cost: {
input: 1.25,
output: 10,
- cacheRead: 0.13,
+ cacheRead: 0.125,
cacheWrite: 0,
},
contextWindow: 400000,
@@ -12115,25 +12404,8 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.036,
- output: 0.18,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 131072,
- maxTokens: 4096,
- } satisfies Model<"openai-completions">,
- "openai/gpt-oss-120b:free": {
- id: "openai/gpt-oss-120b:free",
- name: "OpenAI: gpt-oss-120b (free)",
- api: "openai-completions",
- provider: "openrouter",
- baseUrl: "https://openrouter.ai/api/v1",
- reasoning: true,
- input: ["text"],
- cost: {
- input: 0,
- output: 0,
+ input: 0.037,
+ output: 0.16999999999999998,
cacheRead: 0,
cacheWrite: 0,
},
@@ -12149,13 +12421,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.029,
- output: 0.14,
- cacheRead: 0,
+ input: 0.03,
+ output: 0.13,
+ cacheRead: 0.03,
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 4096,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"openai/gpt-oss-20b:free": {
id: "openai/gpt-oss-20b:free",
@@ -12575,7 +12847,7 @@ export const MODELS = {
input: ["text"],
cost: {
input: 0.09,
- output: 0.09999999999999999,
+ output: 0.55,
cacheRead: 0,
cacheWrite: 0,
},
@@ -12625,13 +12897,13 @@ export const MODELS = {
reasoning: false,
input: ["text"],
cost: {
- input: 0.04815,
- output: 0.19305,
+ input: 0.09999999999999999,
+ output: 0.3,
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 131072,
- maxTokens: 32000,
+ contextWindow: 262144,
+ maxTokens: 4096,
} satisfies Model<"openai-completions">,
"qwen/qwen3-30b-a3b-thinking-2507": {
id: "qwen/qwen3-30b-a3b-thinking-2507",
@@ -12693,9 +12965,9 @@ export const MODELS = {
reasoning: false,
input: ["text"],
cost: {
- input: 0.22,
- output: 1.7999999999999998,
- cacheRead: 0,
+ input: 0.3,
+ output: 1,
+ cacheRead: 0.09999999999999999,
cacheWrite: 0,
},
contextWindow: 1048576,
@@ -12744,7 +13016,7 @@ export const MODELS = {
reasoning: false,
input: ["text"],
cost: {
- input: 0.11,
+ input: 0.12,
output: 0.7999999999999999,
cacheRead: 0.07,
cacheWrite: 0,
@@ -12829,13 +13101,13 @@ export const MODELS = {
reasoning: false,
input: ["text"],
cost: {
- input: 0.09,
+ input: 0.09999999999999999,
output: 1.1,
- cacheRead: 0,
+ cacheRead: 0.07,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 16384,
+ maxTokens: 262144,
} satisfies Model<"openai-completions">,
"qwen/qwen3-next-80b-a3b-instruct:free": {
id: "qwen/qwen3-next-80b-a3b-instruct:free",
@@ -12880,13 +13152,13 @@ export const MODELS = {
reasoning: false,
input: ["text", "image"],
cost: {
- input: 0.19999999999999998,
- output: 0.88,
- cacheRead: 0.11,
+ input: 0.21,
+ output: 1.9,
+ cacheRead: 0.09999999999999999,
cacheWrite: 0,
},
- contextWindow: 262144,
- maxTokens: 16384,
+ contextWindow: 131072,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
"qwen/qwen3-vl-235b-a22b-thinking": {
id: "qwen/qwen3-vl-235b-a22b-thinking",
@@ -13005,7 +13277,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 262144,
+ maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen/qwen3.5-27b": {
id: "qwen/qwen3.5-27b",
@@ -13035,11 +13307,11 @@ export const MODELS = {
cost: {
input: 0.14,
output: 1,
- cacheRead: 0.049999999999999996,
+ cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 81920,
+ maxTokens: 262144,
} satisfies Model<"openai-completions">,
"qwen/qwen3.5-397b-a17b": {
id: "qwen/qwen3.5-397b-a17b",
@@ -13050,13 +13322,13 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.385,
- output: 2.4499999999999997,
- cacheRead: 0.111,
+ input: 0.44999999999999996,
+ output: 3,
+ cacheRead: 0.22499999999999998,
cacheWrite: 0,
},
- contextWindow: 256000,
- maxTokens: 4096,
+ contextWindow: 262144,
+ maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen/qwen3.5-9b": {
id: "qwen/qwen3.5-9b",
@@ -13135,13 +13407,13 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.28500000000000003,
- output: 2.4,
- cacheRead: 0.15,
+ input: 0.44999999999999996,
+ output: 2.7,
+ cacheRead: 0,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 262140,
+ maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen/qwen3.6-35b-a3b": {
id: "qwen/qwen3.6-35b-a3b",
@@ -13220,10 +13492,10 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 1.25,
- output: 3.75,
- cacheRead: 0.25,
- cacheWrite: 1.5625,
+ input: 1.475,
+ output: 4.425,
+ cacheRead: 0.295,
+ cacheWrite: 1.84375,
},
contextWindow: 1000000,
maxTokens: 65536,
@@ -13356,13 +13628,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.14,
- output: 0.58,
- cacheRead: 0.035,
+ input: 0.19999999999999998,
+ output: 0.7999999999999999,
+ cacheRead: 0.049999999999999996,
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 4096,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"tencent/hy3-preview": {
id: "tencent/hy3-preview",
@@ -13509,13 +13781,13 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.105,
+ input: 0.14,
output: 0.28,
- cacheRead: 0.028,
+ cacheRead: 0.0028,
cacheWrite: 0,
},
contextWindow: 1048576,
- maxTokens: 4096,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"xiaomi/mimo-v2.5-pro": {
id: "xiaomi/mimo-v2.5-pro",
@@ -13594,9 +13866,9 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.43,
- output: 1.74,
- cacheRead: 0.08,
+ input: 0.5,
+ output: 2,
+ cacheRead: 0.09999999999999999,
cacheWrite: 0,
},
contextWindow: 202752,
@@ -13645,13 +13917,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.06,
+ input: 0.060500000000000005,
output: 0.39999999999999997,
- cacheRead: 0.01,
+ cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 202752,
- maxTokens: 16384,
+ contextWindow: 200000,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"z-ai/glm-5": {
id: "z-ai/glm-5",
@@ -13668,7 +13940,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 202752,
- maxTokens: 4096,
+ maxTokens: 202752,
} satisfies Model<"openai-completions">,
"z-ai/glm-5-turbo": {
id: "z-ai/glm-5-turbo",
@@ -13684,7 +13956,7 @@ export const MODELS = {
cacheRead: 0.24,
cacheWrite: 0,
},
- contextWindow: 262144,
+ contextWindow: 202752,
maxTokens: 131072,
} satisfies Model<"openai-completions">,
"z-ai/glm-5.1": {
@@ -13713,13 +13985,13 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.54,
- output: 1.76,
- cacheRead: 0.09999999999999999,
+ input: 0.8428,
+ output: 2.6488,
+ cacheRead: 0.15652,
cacheWrite: 0,
},
contextWindow: 1048576,
- maxTokens: 101376,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"z-ai/glm-5v-turbo": {
id: "z-ai/glm-5v-turbo",
@@ -13849,9 +14121,9 @@ export const MODELS = {
reasoning: true,
input: ["text", "image"],
cost: {
- input: 0.65,
+ input: 0.66,
output: 3.41,
- cacheRead: 0.14,
+ cacheRead: 0.15,
cacheWrite: 0,
},
contextWindow: 262144,
@@ -14129,7 +14401,7 @@ export const MODELS = {
provider: "prime-inference",
baseUrl: "https://api.pinference.ai/api/v1",
compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
- reasoning: true,
+ reasoning: false,
input: ["text"],
cost: {
input: 0.045,
@@ -14137,8 +14409,8 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 131072,
- maxTokens: 131072,
+ contextWindow: 128000,
+ maxTokens: 8192,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-chat": {
id: "deepseek/deepseek-chat",
@@ -14174,7 +14446,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 163840,
- maxTokens: 16384,
+ maxTokens: 65536,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-chat-v3.1": {
id: "deepseek/deepseek-chat-v3.1",
@@ -14209,7 +14481,7 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 163840,
+ contextWindow: 131072,
maxTokens: 32768,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-v3.2": {
@@ -14227,8 +14499,8 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 131072,
- maxTokens: 64000,
+ contextWindow: 163840,
+ maxTokens: 65536,
featured: true,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-v3.2-exp": {
@@ -14266,7 +14538,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 1048576,
- maxTokens: 65536,
+ maxTokens: 8192,
featured: true,
} satisfies Model<"openai-completions">,
"deepseek/deepseek-v4-pro": {
@@ -14413,26 +14685,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 16384,
- } satisfies Model<"openai-completions">,
- "internal/glm-5.2-fast": {
- id: "internal/glm-5.2-fast",
- name: "GLM 5.2 Fast",
- api: "openai-completions",
- provider: "prime-inference",
- baseUrl: "https://api.pinference.ai/api/v1",
- compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":false,"maxTokensField":"max_tokens","supportsStrictMode":false,"thinkingFormat":"zai"},
- reasoning: true,
- input: ["text"],
- cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 1048576,
- maxTokens: 101376,
- featured: true,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"meta-llama/Llama-3.2-1B-Instruct": {
id: "meta-llama/Llama-3.2-1B-Instruct",
@@ -14486,7 +14739,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 16384,
+ maxTokens: 128000,
} satisfies Model<"openai-completions">,
"meta-llama/llama-4-maverick": {
id: "meta-llama/llama-4-maverick",
@@ -14540,7 +14793,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 204800,
- maxTokens: 196608,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"minimax/minimax-m3": {
id: "minimax/minimax-m3",
@@ -14595,7 +14848,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 8192,
+ maxTokens: 16384,
} satisfies Model<"openai-completions">,
"mistralai/mistral-small-24b-instruct-2501": {
id: "mistralai/mistral-small-24b-instruct-2501",
@@ -14648,8 +14901,8 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 128000,
- maxTokens: 16384,
+ contextWindow: 131072,
+ maxTokens: 8192,
} satisfies Model<"openai-completions">,
"mistralai/mixtral-8x22b-instruct": {
id: "mistralai/mixtral-8x22b-instruct",
@@ -15172,6 +15425,139 @@ export const MODELS = {
maxTokens: 128000,
featured: true,
} satisfies Model<"openai-completions">,
+ "openai/gpt-5.6": {
+ id: "openai/gpt-5.6",
+ name: "GPT 5.6",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 128000,
+ maxTokens: 8192,
+ } satisfies Model<"openai-completions">,
+ "openai/gpt-5.6-luna": {
+ id: "openai/gpt-5.6-luna",
+ name: "GPT 5.6 Luna",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 1,
+ output: 6,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
+ "openai/gpt-5.6-luna-pro": {
+ id: "openai/gpt-5.6-luna-pro",
+ name: "GPT 5.6 Luna PRO",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 1,
+ output: 6,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
+ "openai/gpt-5.6-sol": {
+ id: "openai/gpt-5.6-sol",
+ name: "GPT 5.6 SOL",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
+ "openai/gpt-5.6-sol-pro": {
+ id: "openai/gpt-5.6-sol-pro",
+ name: "GPT 5.6 SOL PRO",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 5,
+ output: 30,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
+ "openai/gpt-5.6-terra": {
+ id: "openai/gpt-5.6-terra",
+ name: "GPT 5.6 Terra",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 2.5,
+ output: 15,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
+ "openai/gpt-5.6-terra-pro": {
+ id: "openai/gpt-5.6-terra-pro",
+ name: "GPT 5.6 Terra PRO",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ compat: {"supportsStore":false,"supportsDeveloperRole":false,"supportsReasoningEffort":true,"maxTokensField":"max_tokens","supportsStrictMode":false},
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","minimal":null,"max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 2.5,
+ output: 15,
+ cacheRead: 0,
+ cacheWrite: 0,
+ },
+ contextWindow: 1050000,
+ maxTokens: 128000,
+ } satisfies Model<"openai-completions">,
"openai/gpt-oss-120b": {
id: "openai/gpt-oss-120b",
name: "GPT OSS 120B",
@@ -15188,7 +15574,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 131072,
- maxTokens: 8192,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"openai/gpt-oss-20b": {
id: "openai/gpt-oss-20b",
@@ -15260,7 +15646,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 32000,
+ maxTokens: 8192,
featured: true,
} satisfies Model<"openai-completions">,
"qwen/qwen3-8b": {
@@ -15352,8 +15738,8 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 262144,
- maxTokens: 16384,
+ contextWindow: 131072,
+ maxTokens: 32768,
} satisfies Model<"openai-completions">,
"qwen/qwen3-vl-235b-a22b-thinking": {
id: "qwen/qwen3-vl-235b-a22b-thinking",
@@ -15426,7 +15812,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 81920,
+ maxTokens: 262144,
} satisfies Model<"openai-completions">,
"qwen/qwen3.5-397b-a17b": {
id: "qwen/qwen3.5-397b-a17b",
@@ -15443,7 +15829,7 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 256000,
+ contextWindow: 262144,
maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen/qwen3.6-27b": {
@@ -15462,7 +15848,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 262144,
- maxTokens: 262140,
+ maxTokens: 65536,
} satisfies Model<"openai-completions">,
"qwen/qwen3.6-35b-a3b": {
id: "qwen/qwen3.6-35b-a3b",
@@ -15643,8 +16029,8 @@ export const MODELS = {
cacheRead: 0,
cacheWrite: 0,
},
- contextWindow: 202752,
- maxTokens: 16384,
+ contextWindow: 200000,
+ maxTokens: 131072,
} satisfies Model<"openai-completions">,
"z-ai/glm-5": {
id: "z-ai/glm-5",
@@ -15700,7 +16086,7 @@ export const MODELS = {
cacheWrite: 0,
},
contextWindow: 1048576,
- maxTokens: 101376,
+ maxTokens: 131072,
featured: true,
} satisfies Model<"openai-completions">,
},
@@ -16198,23 +16584,6 @@ export const MODELS = {
contextWindow: 200000,
maxTokens: 4096,
} satisfies Model<"anthropic-messages">,
- "anthropic/claude-3.5-haiku": {
- id: "anthropic/claude-3.5-haiku",
- name: "Claude 3.5 Haiku",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
- input: ["text", "image"],
- cost: {
- input: 0.7999999999999999,
- output: 4,
- cacheRead: 0.08,
- cacheWrite: 1,
- },
- contextWindow: 200000,
- maxTokens: 8192,
- } satisfies Model<"anthropic-messages">,
"anthropic/claude-fable-5": {
id: "anthropic/claude-fable-5",
name: "Claude Fable 5",
@@ -16265,7 +16634,7 @@ export const MODELS = {
cacheWrite: 18.75,
},
contextWindow: 200000,
- maxTokens: 32000,
+ maxTokens: 8192,
} satisfies Model<"anthropic-messages">,
"anthropic/claude-opus-4.1": {
id: "anthropic/claude-opus-4.1",
@@ -16337,6 +16706,24 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
+ "anthropic/claude-opus-4.7-fast": {
+ id: "anthropic/claude-opus-4.7-fast",
+ name: "Claude Opus 4.7 (Fast)",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 30,
+ output: 150,
+ cacheRead: 3,
+ cacheWrite: 37.5,
+ },
+ contextWindow: 1000000,
+ maxTokens: 128000,
+ } satisfies Model<"anthropic-messages">,
"anthropic/claude-opus-4.8": {
id: "anthropic/claude-opus-4.8",
name: "Claude Opus 4.8",
@@ -16355,6 +16742,24 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
+ "anthropic/claude-opus-4.8-fast": {
+ id: "anthropic/claude-opus-4.8-fast",
+ name: "Claude Opus 4.8 (Fast)",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ thinkingLevelMap: {"xhigh":"xhigh","max":"max"},
+ input: ["text", "image"],
+ cost: {
+ input: 10,
+ output: 50,
+ cacheRead: 1,
+ cacheWrite: 12.5,
+ },
+ contextWindow: 1000000,
+ maxTokens: 128000,
+ } satisfies Model<"anthropic-messages">,
"anthropic/claude-sonnet-4": {
id: "anthropic/claude-sonnet-4",
name: "Claude Sonnet 4",
@@ -16370,7 +16775,7 @@ export const MODELS = {
cacheWrite: 3.75,
},
contextWindow: 1000000,
- maxTokens: 64000,
+ maxTokens: 8192,
} satisfies Model<"anthropic-messages">,
"anthropic/claude-sonnet-4.5": {
id: "anthropic/claude-sonnet-4.5",
@@ -16425,23 +16830,6 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
- "arcee-ai/trinity-large-preview": {
- id: "arcee-ai/trinity-large-preview",
- name: "Trinity Large Preview",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
- input: ["text"],
- cost: {
- input: 0.25,
- output: 1,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 131000,
- maxTokens: 131000,
- } satisfies Model<"anthropic-messages">,
"arcee-ai/trinity-large-thinking": {
id: "arcee-ai/trinity-large-thinking",
name: "Trinity Large Thinking",
@@ -16570,12 +16958,12 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 0.6,
- output: 1.7,
- cacheRead: 0,
+ input: 0.25,
+ output: 0.95,
+ cacheRead: 0.13,
cacheWrite: 0,
},
- contextWindow: 128000,
+ contextWindow: 163840,
maxTokens: 128000,
} satisfies Model<"anthropic-messages">,
"deepseek/deepseek-v3.1-terminus": {
@@ -16640,7 +17028,7 @@ export const MODELS = {
cost: {
input: 0.14,
output: 0.28,
- cacheRead: 0.0028,
+ cacheRead: 0.028,
cacheWrite: 0,
},
contextWindow: 1000000,
@@ -16901,6 +17289,23 @@ export const MODELS = {
contextWindow: 1000000,
maxTokens: 32000,
} satisfies Model<"anthropic-messages">,
+ "kwaipilot/kat-coder-air-v2.5": {
+ id: "kwaipilot/kat-coder-air-v2.5",
+ name: "Kat Coder Air V2.5",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text"],
+ cost: {
+ input: 0.15,
+ output: 0.6,
+ cacheRead: 0.03,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 80000,
+ } satisfies Model<"anthropic-messages">,
"kwaipilot/kat-coder-pro-v1": {
id: "kwaipilot/kat-coder-pro-v1",
name: "KAT-Coder-Pro V1",
@@ -16935,39 +17340,22 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 256000,
} satisfies Model<"anthropic-messages">,
- "meituan/longcat-flash-chat": {
- id: "meituan/longcat-flash-chat",
- name: "LongCat Flash Chat",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
- input: ["text"],
- cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 128000,
- maxTokens: 100000,
- } satisfies Model<"anthropic-messages">,
- "meituan/longcat-flash-thinking-2601": {
- id: "meituan/longcat-flash-thinking-2601",
- name: "LongCat Flash Thinking 2601",
+ "kwaipilot/kat-coder-pro-v2.5": {
+ id: "kwaipilot/kat-coder-pro-v2.5",
+ name: "Kat Coder Pro V2.5",
api: "anthropic-messages",
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
input: ["text"],
cost: {
- input: 0,
- output: 0,
- cacheRead: 0,
+ input: 0.74,
+ output: 2.96,
+ cacheRead: 0.15,
cacheWrite: 0,
},
- contextWindow: 32768,
- maxTokens: 32768,
+ contextWindow: 256000,
+ maxTokens: 80000,
} satisfies Model<"anthropic-messages">,
"meta/llama-3.1-70b": {
id: "meta/llama-3.1-70b",
@@ -17095,7 +17483,7 @@ export const MODELS = {
provider: "vercel-ai-gateway",
baseUrl: "https://ai-gateway.vercel.sh",
reasoning: true,
- input: ["text"],
+ input: ["text", "image"],
cost: {
input: 1.25,
output: 4.25,
@@ -17275,23 +17663,6 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 256000,
} satisfies Model<"anthropic-messages">,
- "mistral/devstral-small": {
- id: "mistral/devstral-small",
- name: "Devstral Small 1.1",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
- input: ["text"],
- cost: {
- input: 0.09999999999999999,
- output: 0.3,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 128000,
- maxTokens: 64000,
- } satisfies Model<"anthropic-messages">,
"mistral/devstral-small-2": {
id: "mistral/devstral-small-2",
name: "Devstral Small 2",
@@ -17496,23 +17867,6 @@ export const MODELS = {
contextWindow: 128000,
maxTokens: 4000,
} satisfies Model<"anthropic-messages">,
- "mistral/pixtral-large": {
- id: "mistral/pixtral-large",
- name: "Pixtral Large",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: false,
- input: ["text", "image"],
- cost: {
- input: 2,
- output: 6,
- cacheRead: 0,
- cacheWrite: 0,
- },
- contextWindow: 128000,
- maxTokens: 4000,
- } satisfies Model<"anthropic-messages">,
"moonshotai/kimi-k2": {
id: "moonshotai/kimi-k2",
name: "Kimi K2 Instruct",
@@ -18480,6 +18834,23 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 256000,
} satisfies Model<"anthropic-messages">,
+ "thinkingmachines/inkling": {
+ id: "thinkingmachines/inkling",
+ name: "Inkling",
+ api: "anthropic-messages",
+ provider: "vercel-ai-gateway",
+ baseUrl: "https://ai-gateway.vercel.sh",
+ reasoning: true,
+ input: ["text", "image"],
+ cost: {
+ input: 1,
+ output: 4.05,
+ cacheRead: 0.16999999999999998,
+ cacheWrite: 0,
+ },
+ contextWindow: 256000,
+ maxTokens: 256000,
+ } satisfies Model<"anthropic-messages">,
"xai/grok-4.1-fast-non-reasoning": {
id: "xai/grok-4.1-fast-non-reasoning",
name: "Grok 4.1 Fast Non-Reasoning",
@@ -18667,40 +19038,6 @@ export const MODELS = {
contextWindow: 256000,
maxTokens: 256000,
} satisfies Model<"anthropic-messages">,
- "xiaomi/mimo-v2-flash": {
- id: "xiaomi/mimo-v2-flash",
- name: "MiMo V2 Flash",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
- input: ["text"],
- cost: {
- input: 0.09999999999999999,
- output: 0.3,
- cacheRead: 0.01,
- cacheWrite: 0,
- },
- contextWindow: 262144,
- maxTokens: 32000,
- } satisfies Model<"anthropic-messages">,
- "xiaomi/mimo-v2-pro": {
- id: "xiaomi/mimo-v2-pro",
- name: "MiMo V2 Pro",
- api: "anthropic-messages",
- provider: "vercel-ai-gateway",
- baseUrl: "https://ai-gateway.vercel.sh",
- reasoning: true,
- input: ["text"],
- cost: {
- input: 1,
- output: 3,
- cacheRead: 0.19999999999999998,
- cacheWrite: 0,
- },
- contextWindow: 1000000,
- maxTokens: 128000,
- } satisfies Model<"anthropic-messages">,
"xiaomi/mimo-v2.5": {
id: "xiaomi/mimo-v2.5",
name: "MiMo M2.5",
@@ -18965,9 +19302,9 @@ export const MODELS = {
reasoning: true,
input: ["text"],
cost: {
- input: 3,
- output: 10.25,
- cacheRead: 0.5,
+ input: 2.0999999999999996,
+ output: 6.6000000000000005,
+ cacheRead: 0.21,
cacheWrite: 0,
},
contextWindow: 1000000,
diff --git a/packages/ai/test/openai-completions-empty-tools.test.ts b/packages/ai/test/openai-completions-empty-tools.test.ts
index 8197efb0a1..0fbdc7ab34 100644
--- a/packages/ai/test/openai-completions-empty-tools.test.ts
+++ b/packages/ai/test/openai-completions-empty-tools.test.ts
@@ -1,6 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { getModel } from "../src/models.js";
import { streamSimple } from "../src/stream.js";
+import type { Model } from "../src/types.js";
// Empty tools arrays must NOT be serialized as `tools: []` — some OpenAI-compatible
// backends (e.g. DashScope / Aliyun Qwen via compatible-mode) reject the request with
@@ -129,6 +130,37 @@ describe("openai-completions empty tools handling", () => {
expect(clientOptions.defaultHeaders?.["cf-aig-authorization"]).toBe("Bearer test");
});
+ it("uses OpenAI reasoning fields for an explicitly configured private Prime Inference route", async () => {
+ const model: Model<"openai-completions"> = {
+ id: "internal/glm-5.2-fast",
+ name: "GLM 5.2 Fast",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ reasoning: true,
+ input: ["text"],
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
+ contextWindow: 400000,
+ maxTokens: 131072,
+ compat: {
+ supportsDeveloperRole: false,
+ maxTokensField: "max_tokens",
+ },
+ };
+
+ await streamSimple(
+ model,
+ {
+ messages: [{ role: "user", content: "hi", timestamp: Date.now() }],
+ },
+ { apiKey: "test", reasoning: "medium" },
+ ).result();
+
+ const params = mockState.lastParams as { reasoning_effort?: string; enable_thinking?: boolean };
+ expect(params.reasoning_effort).toBe("medium");
+ expect(params.enable_thinking).toBeUndefined();
+ });
+
it("preserves inline upstream Authorization for Cloudflare AI Gateway BYOK requests", async () => {
process.env.CLOUDFLARE_ACCOUNT_ID = "account-id";
process.env.CLOUDFLARE_GATEWAY_ID = "gateway-id";
diff --git a/packages/ai/test/prime-inference-models.test.ts b/packages/ai/test/prime-inference-models.test.ts
index 64cc129394..9d373c2c55 100644
--- a/packages/ai/test/prime-inference-models.test.ts
+++ b/packages/ai/test/prime-inference-models.test.ts
@@ -27,7 +27,6 @@ describe("Prime Inference models", () => {
"anthropic/claude-sonnet-5",
"deepseek/deepseek-v4-pro",
"google/gemini-2.5-pro",
- "internal/glm-5.2-fast",
"meta-llama/llama-4-maverick",
"minimax/minimax-m3",
"moonshotai/kimi-k2.7-code",
@@ -47,9 +46,10 @@ describe("Prime Inference models", () => {
);
});
- it("skips raw and duplicate catalog variants", () => {
+ it("skips private, raw, and duplicate catalog variants", () => {
const modelIds = getModels("prime-inference").map((model) => model.id);
+ expect(modelIds.filter((id) => id.startsWith("internal/"))).toEqual([]);
expect(modelIds).not.toContain("zai-org/GLM-4.7");
expect(modelIds).not.toContain("nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16");
expect(modelIds).not.toContain("Qwen/Qwen3.5-4B");
@@ -59,7 +59,6 @@ describe("Prime Inference models", () => {
it("marks flagship models as featured so pickers can pin them above the long tail", () => {
expect(getModel("prime-inference", "openai/gpt-5.5").featured).toBe(true);
expect(getModel("prime-inference", "z-ai/glm-5.2").featured).toBe(true);
- expect(getModel("prime-inference", "internal/glm-5.2-fast").featured).toBe(true);
expect(getModel("prime-inference", "google/gemini-2.5-pro").featured).toBeUndefined();
expect(getModel("prime-inference", "openai/gpt-4o").featured).toBeUndefined();
});
@@ -112,38 +111,6 @@ describe("Prime Inference models", () => {
});
});
- it("registers the internal GLM 5.2 Fast route", () => {
- const model = getModel("prime-inference", "internal/glm-5.2-fast");
-
- expect(model).toBeDefined();
- expect(model.name).toBe("GLM 5.2 Fast");
- expect(model.api).toBe("openai-completions");
- expect(model.provider).toBe("prime-inference");
- expect(model.baseUrl).toBe("https://api.pinference.ai/api/v1");
- expect(model.reasoning).toBe(true);
- expect(model.input).toEqual(["text"]);
- // CI preserves this team-only route from the generated snapshot while the
- // public route is refreshed from live metadata, so validate coherent limits
- // without coupling the two independently sourced entries.
- expect(model.contextWindow).toBeGreaterThan(0);
- expect(model.maxTokens).toBeGreaterThan(0);
- expect(model.maxTokens).toBeLessThanOrEqual(model.contextWindow);
- expect(model.cost).toEqual({
- input: 0,
- output: 0,
- cacheRead: 0,
- cacheWrite: 0,
- });
- expect(model.compat).toEqual({
- supportsStore: false,
- supportsDeveloperRole: false,
- supportsReasoningEffort: false,
- maxTokensField: "max_tokens",
- supportsStrictMode: false,
- thinkingFormat: "zai",
- });
- });
-
it("marks known reasoning-capable Prime Inference model families", () => {
const opus48 = getModel("prime-inference", "anthropic/claude-opus-4.8");
expect(opus48.reasoning).toBe(true);
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index 23545c2701..2fcf755a37 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -2,6 +2,7 @@
## [Unreleased]
+- Fixed team-gated Prime Inference routes being missing from model selectors by merging the authenticated team catalog during model refresh ([ENG-4645](https://linear.app/primeintellect/issue/ENG-4645/internalglm-52-fast-isnt-working)).
- Added confirmation when fullscreen text selection copies to the clipboard ([ENG-4644](https://linear.app/primeintellect/issue/ENG-4644/copy-issues)).
- Added compact file change stats to collapsed tool calls and an agent-run edit total above the recap.
- Changed tool expansion hints to appear only on the latest tool row instead of every tool call ([ENG-4583](https://linear.app/primeintellect/issue/ENG-4583/too-many-ctrlo-alerts)).
diff --git a/packages/coding-agent/src/cli/list-models.ts b/packages/coding-agent/src/cli/list-models.ts
index 7d5385737e..a3d04a480b 100644
--- a/packages/coding-agent/src/cli/list-models.ts
+++ b/packages/coding-agent/src/cli/list-models.ts
@@ -32,7 +32,7 @@ export async function listModels(modelRegistry: ModelRegistry, searchPattern?: s
console.error(chalk.yellow(`Warning: errors loading models.json:\n${loadError}`));
}
- const models = modelRegistry.getAvailable();
+ const models = await modelRegistry.refreshAvailableModels();
if (models.length === 0) {
console.log(formatNoModelsAvailableMessage());
diff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.ts
index e51ab69002..f93562ba8e 100644
--- a/packages/coding-agent/src/core/agent-session.ts
+++ b/packages/coding-agent/src/core/agent-session.ts
@@ -4103,13 +4103,16 @@ export class AgentSession {
/**
* Set model directly.
- * Validates that auth is configured, saves to session and settings.
- * @throws Error if no auth is configured for the model
+ * Validates that the model is available, saves to session and settings.
+ * @throws Error if the model is not available
*/
async setModel(model: Model<any>, options: ModelSelectOptions = {}): Promise<void> {
if (!this._modelRegistry.hasConfiguredAuth(model)) {
throw new Error(`No API key for ${model.provider}/${model.id}`);
}
+ if (!(await this._modelRegistry.canUseModel(model))) {
+ throw new Error(`Model "${model.provider}/${model.id}" is not available for the current Prime team.`);
+ }
const previousModel = this.model;
const thinkingLevel = this._getThinkingLevelForModelSwitch();
@@ -4170,7 +4173,10 @@ export class AgentSession {
direction: "forward" | "backward",
options: ModelSelectOptions,
): Promise<ModelCycleResult | undefined> {
- const scopedModels = this._scopedModels.filter((scoped) => this._modelRegistry.hasConfiguredAuth(scoped.model));
+ const availableModels = await this._modelRegistry.refreshAvailableModels();
+ const scopedModels = this._scopedModels.filter((scoped) =>
+ availableModels.some((model) => modelsAreEqual(model, scoped.model)),
+ );
if (scopedModels.length <= 1) return undefined;
const currentModel = this.model;
@@ -4207,7 +4213,7 @@ export class AgentSession {
direction: "forward" | "backward",
options: ModelSelectOptions,
): Promise<ModelCycleResult | undefined> {
- const availableModels = await this._modelRegistry.getAvailable();
+ const availableModels = await this._modelRegistry.refreshAvailableModels();
if (availableModels.length <= 1) return undefined;
const currentModel = this.model;
diff --git a/packages/coding-agent/src/core/model-registry.ts b/packages/coding-agent/src/core/model-registry.ts
index 3bbe512f6a..eb41d60c16 100644
--- a/packages/coding-agent/src/core/model-registry.ts
+++ b/packages/coding-agent/src/core/model-registry.ts
@@ -28,6 +28,12 @@ import type { Validator } from "typebox/compile";
import type { TLocalizedValidationError } from "typebox/error";
import { getAgentDir } from "../config.js";
import type { AuthSourceToken, AuthStatus, AuthStorage } from "./auth-storage.js";
+import { PRIME_INFERENCE_PROVIDER_ID } from "./prime-inference-auth.js";
+import {
+ fetchAuthorizedPrivatePrimeInferenceModelIds,
+ getPrivatePrimeInferenceModels,
+ isPrivatePrimeInferenceModel,
+} from "./prime-inference-models.js";
import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "./provider-display-names.js";
import {
clearConfigValueCache,
@@ -358,6 +364,9 @@ export class ModelRegistry {
private lastProviderAuthSourceTokens: Map<string, AuthSourceToken> = new Map();
private modelRequestHeaders: Map<string, Record<string, string>> = new Map();
private registeredProviders: Map<string, ProviderConfigInput> = new Map();
+ private authorizedPrivatePrimeInferenceModelIds = new Set<string>();
+ private authorizedPrivatePrimeInferenceTeamId: string | undefined;
+ private explicitPrivatePrimeInferenceModelIds = new Set<string>();
private loadError: string | undefined = undefined;
/** Re-register dynamic OAuth providers (e.g. user MCP servers) after refresh() resets the registry. */
@@ -389,6 +398,9 @@ export class ModelRegistry {
this.providerRequestConfigs.clear();
this.modelRequestHeaders.clear();
this.lastProviderAuthSourceTokens.clear();
+ this.authorizedPrivatePrimeInferenceModelIds.clear();
+ this.authorizedPrivatePrimeInferenceTeamId = undefined;
+ this.explicitPrivatePrimeInferenceModelIds.clear();
this.loadError = undefined;
// Credentials may have been written by another process (e.g. the UI
@@ -436,7 +448,10 @@ export class ModelRegistry {
// Keep built-in models even if custom models failed to load
}
- const builtInModels = this.loadBuiltInModels(overrides, modelOverrides);
+ this.explicitPrivatePrimeInferenceModelIds = new Set(
+ customModels.filter(isPrivatePrimeInferenceModel).map((model) => model.id),
+ );
+ const builtInModels = [...this.loadBuiltInModels(overrides, modelOverrides), ...getPrivatePrimeInferenceModels()];
let combined = this.mergeCustomModels(builtInModels, customModels);
// Let OAuth providers modify their models (e.g., update baseUrl)
@@ -682,7 +697,54 @@ export class ModelRegistry {
* This is a fast check that doesn't refresh OAuth tokens.
*/
getAvailable(): Model<Api>[] {
- return this.models.filter((m) => this.hasConfiguredAuth(m));
+ return this.models.filter((model) => {
+ if (
+ isPrivatePrimeInferenceModel(model) &&
+ !this.explicitPrivatePrimeInferenceModelIds.has(model.id) &&
+ !this.authorizedPrivatePrimeInferenceModelIds.has(model.id)
+ ) {
+ return false;
+ }
+ return this.hasConfiguredAuth(model);
+ });
+ }
+
+ async refreshAvailableModels(): Promise<Model<Api>[]> {
+ const previousPrivateModelIds = new Set(this.authorizedPrivatePrimeInferenceModelIds);
+ const previousTeamId = this.authorizedPrivatePrimeInferenceTeamId;
+ this.refresh();
+ const apiKey = await this.authStorage.getApiKey(PRIME_INFERENCE_PROVIDER_ID);
+ const teamHeaders = this.authStorage.getProviderHeaders(PRIME_INFERENCE_PROVIDER_ID);
+ const teamId = teamHeaders?.["X-Prime-Team-ID"];
+ if (!apiKey || !teamHeaders || !teamId) {
+ return this.getAvailable();
+ }
+
+ try {
+ this.authorizedPrivatePrimeInferenceModelIds = await fetchAuthorizedPrivatePrimeInferenceModelIds(
+ apiKey,
+ teamHeaders,
+ );
+ this.authorizedPrivatePrimeInferenceTeamId = teamId;
+ } catch {
+ if (teamId === previousTeamId) {
+ this.authorizedPrivatePrimeInferenceModelIds = previousPrivateModelIds;
+ this.authorizedPrivatePrimeInferenceTeamId = teamId;
+ }
+ }
+ return this.getAvailable();
+ }
+
+ async canUseModel(model: Model<Api>): Promise<boolean> {
+ if (!this.hasConfiguredAuth(model)) {
+ return false;
+ }
+ if (!isPrivatePrimeInferenceModel(model)) {
+ return true;
+ }
+
+ const availableModels = await this.refreshAvailableModels();
+ return availableModels.some((candidate) => candidate.provider === model.provider && candidate.id === model.id);
}
/**
diff --git a/packages/coding-agent/src/core/model-resolver.ts b/packages/coding-agent/src/core/model-resolver.ts
index 4f06123a75..78bdafb6ee 100644
--- a/packages/coding-agent/src/core/model-resolver.ts
+++ b/packages/coding-agent/src/core/model-resolver.ts
@@ -9,6 +9,7 @@ import { minimatch } from "minimatch";
import { isValidThinkingLevel } from "../cli/args.js";
import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
import type { ModelRegistry } from "./model-registry.js";
+import { isPrivatePrimeInferenceModel } from "./prime-inference-models.js";
const log = getLogger("coding-agent.model-resolver");
@@ -338,7 +339,7 @@ export function resolveModelScopeFromModels(patterns: string[], availableModels:
}
export async function resolveModelScope(patterns: string[], modelRegistry: ModelRegistry): Promise<ScopedModel[]> {
- const availableModels = await modelRegistry.getAvailable();
+ const availableModels = await modelRegistry.refreshAvailableModels();
return resolveModelScopeFromModels(patterns, availableModels);
}
@@ -533,6 +534,11 @@ export async function findInitialModel(options: {
let model: Model<Api> | undefined;
let thinkingLevel: ThinkingLevel = DEFAULT_THINKING_LEVEL;
+ let cachedAvailableModels: Model<Api>[] | undefined;
+ const getAvailableModels = async (): Promise<Model<Api>[]> => {
+ cachedAvailableModels ??= await modelRegistry.refreshAvailableModels();
+ return cachedAvailableModels;
+ };
// 1. CLI args take priority
if (cliProvider && cliModel) {
@@ -546,8 +552,21 @@ export async function findInitialModel(options: {
console.error(chalk.red(resolved.error));
process.exit(1);
}
- if (resolved.model) {
- return { model: resolved.model, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };
+ const resolvedModel = resolved.model;
+ if (resolvedModel) {
+ if (isPrivatePrimeInferenceModel(resolvedModel)) {
+ const availableModel = (await getAvailableModels()).find((candidate) =>
+ modelsAreEqual(candidate, resolvedModel),
+ );
+ if (!availableModel) {
+ const error = `Model "${resolvedModel.provider}/${resolvedModel.id}" is not available for the current Prime team.`;
+ log.error(error, { cliProvider, cliModel });
+ console.error(chalk.red(error));
+ process.exit(1);
+ }
+ return { model: availableModel, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };
+ }
+ return { model: resolvedModel, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };
}
}
@@ -559,15 +578,20 @@ export async function findInitialModel(options: {
fallbackMessage: undefined,
};
}
+ const availableModels = await getAvailableModels();
// 3. Try saved default from settings
if (defaultProvider && defaultModelId) {
// Rebuild from the provider template when the saved id is missing from this
// build's snapshot (e.g. prime-inference catalog churn), so it survives updates.
const found =
- modelRegistry.find(defaultProvider, defaultModelId) ??
- buildFallbackModel(defaultProvider, defaultModelId, modelRegistry.getAll());
- if (found && modelRegistry.hasConfiguredAuth(found)) {
+ availableModels.find(
+ (candidate) => candidate.provider === defaultProvider && candidate.id === defaultModelId,
+ ) ??
+ (!isPrivatePrimeInferenceModel({ provider: defaultProvider, id: defaultModelId })
+ ? buildFallbackModel(defaultProvider, defaultModelId, availableModels)
+ : undefined);
+ if (found) {
model = found;
if (defaultThinkingLevel) {
thinkingLevel = defaultThinkingLevel;
@@ -577,8 +601,6 @@ export async function findInitialModel(options: {
}
// 4. Try first available model with valid API key
- const availableModels = await modelRegistry.getAvailable();
-
if (availableModels.length > 0) {
const defaultModel = findPreferredDefaultModel(availableModels);
if (defaultModel) {
@@ -603,12 +625,12 @@ export async function restoreModelFromSession(
shouldPrintMessages: boolean,
modelRegistry: ModelRegistry,
): Promise<{ model: Model<Api> | undefined; fallbackMessage: string | undefined }> {
- const restoredModel = modelRegistry.find(savedProvider, savedModelId);
-
- // Check if restored model exists and still has auth configured
- const hasConfiguredAuth = restoredModel ? modelRegistry.hasConfiguredAuth(restoredModel) : false;
+ const availableModels = await modelRegistry.refreshAvailableModels();
+ const restoredModel = availableModels.find(
+ (candidate) => candidate.provider === savedProvider && candidate.id === savedModelId,
+ );
- if (restoredModel && hasConfiguredAuth) {
+ if (restoredModel) {
if (shouldPrintMessages) {
console.log(chalk.dim(`Restored model: ${savedProvider}/${savedModelId}`));
}
@@ -616,7 +638,12 @@ export async function restoreModelFromSession(
}
// Model not found or no API key - fall back
- const reason = !restoredModel ? "model no longer exists" : "no auth configured";
+ const registeredModel = modelRegistry.find(savedProvider, savedModelId);
+ const reason = !registeredModel
+ ? "model no longer exists"
+ : !modelRegistry.hasConfiguredAuth(registeredModel)
+ ? "no auth configured"
+ : "model is not available";
log.warn("could not restore model", { provider: savedProvider, model: savedModelId, reason });
if (shouldPrintMessages) {
@@ -624,19 +651,24 @@ export async function restoreModelFromSession(
}
// If we already have a model, use it as fallback
- if (currentModel) {
+ const availableCurrentModel = currentModel
+ ? availableModels.find((candidate) => modelsAreEqual(candidate, currentModel))
+ : undefined;
+ const fallbackCurrentModel =
+ currentModel && (!isPrivatePrimeInferenceModel(currentModel) || availableCurrentModel)
+ ? (availableCurrentModel ?? currentModel)
+ : undefined;
+ if (fallbackCurrentModel) {
if (shouldPrintMessages) {
- console.log(chalk.dim(`Falling back to: ${currentModel.provider}/${currentModel.id}`));
+ console.log(chalk.dim(`Falling back to: ${fallbackCurrentModel.provider}/${fallbackCurrentModel.id}`));
}
return {
- model: currentModel,
- fallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${currentModel.provider}/${currentModel.id}.`,
+ model: fallbackCurrentModel,
+ fallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${fallbackCurrentModel.provider}/${fallbackCurrentModel.id}.`,
};
}
// Try to find any available model
- const availableModels = await modelRegistry.getAvailable();
-
if (availableModels.length > 0) {
const fallbackModel = findPreferredDefaultModel(availableModels) ?? availableModels[0];
diff --git a/packages/coding-agent/src/core/prime-inference-models.ts b/packages/coding-agent/src/core/prime-inference-models.ts
new file mode 100644
index 0000000000..de2f3789af
--- /dev/null
+++ b/packages/coding-agent/src/core/prime-inference-models.ts
@@ -0,0 +1,76 @@
+import type { Model } from "@earendil-works/pi-ai";
+
+export const PRIME_INFERENCE_BASE_URL = "https://api.pinference.ai/api/v1";
+const PRIVATE_MODEL_REFRESH_TIMEOUT_MS = 10_000;
+
+const PRIVATE_PRIME_INFERENCE_MODELS: readonly Model<"openai-completions">[] = [
+ {
+ id: "internal/glm-5.2-fast",
+ name: "GLM 5.2 Fast",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: PRIME_INFERENCE_BASE_URL,
+ reasoning: true,
+ input: ["text"],
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
+ contextWindow: 400000,
+ maxTokens: 131072,
+ featured: true,
+ compat: {
+ supportsDeveloperRole: false,
+ maxTokensField: "max_tokens",
+ },
+ },
+];
+
+export function isPrivatePrimeInferenceModel(model: Pick<Model<string>, "provider" | "id">): boolean {
+ return model.provider === "prime-inference" && model.id.startsWith("internal/");
+}
+
+export function getPrivatePrimeInferenceModels(): Model<"openai-completions">[] {
+ return PRIVATE_PRIME_INFERENCE_MODELS.map((model) => ({
+ ...model,
+ input: [...model.input],
+ cost: { ...model.cost },
+ compat: model.compat ? { ...model.compat } : undefined,
+ }));
+}
+
+export async function fetchAuthorizedPrivatePrimeInferenceModelIds(
+ apiKey: string,
+ teamHeaders: Record<string, string>,
+ fetchFn: typeof fetch = fetch,
+): Promise<Set<string>> {
+ if (!teamHeaders["X-Prime-Team-ID"]) {
+ return new Set();
+ }
+
+ const response = await fetchFn(`${PRIME_INFERENCE_BASE_URL}/models`, {
+ headers: {
+ Authorization: `Bearer ${apiKey}`,
+ ...teamHeaders,
+ },
+ signal: AbortSignal.timeout(PRIVATE_MODEL_REFRESH_TIMEOUT_MS),
+ });
+ if (response.status === 401 || response.status === 403) {
+ return new Set();
+ }
+ if (!response.ok) {
+ throw new Error(`Prime Inference model catalog request failed with status ${response.status}`);
+ }
+
+ const payload = (await response.json()) as unknown;
+ if (!payload || typeof payload !== "object" || !("data" in payload) || !Array.isArray(payload.data)) {
+ throw new Error("Prime Inference model catalog response is invalid");
+ }
+
+ const knownPrivateIds = new Set(PRIVATE_PRIME_INFERENCE_MODELS.map((model) => model.id));
+ return new Set(
+ payload.data.flatMap((entry) => {
+ if (!entry || typeof entry !== "object" || !("id" in entry) || typeof entry.id !== "string") {
+ return [];
+ }
+ return knownPrivateIds.has(entry.id) ? [entry.id] : [];
+ }),
+ );
+}
diff --git a/packages/coding-agent/src/modes/agent-connection/in-process-agent-connection.ts b/packages/coding-agent/src/modes/agent-connection/in-process-agent-connection.ts
index 9f7ba42f34..7be8683cf4 100644
--- a/packages/coding-agent/src/modes/agent-connection/in-process-agent-connection.ts
+++ b/packages/coding-agent/src/modes/agent-connection/in-process-agent-connection.ts
@@ -108,8 +108,7 @@ export class InProcessAgentConnection implements AgentConnection {
}
async getAvailableModels(): Promise<AgentConnectionModel[]> {
- this.session.modelRegistry.refresh();
- return this.session.modelRegistry.getAvailable();
+ return this.session.modelRegistry.refreshAvailableModels();
}
async getSessionStats(): Promise<SessionStats> {
@@ -273,8 +272,8 @@ export class InProcessAgentConnection implements AgentConnection {
}
async setModel(provider: string, modelId: string): Promise<AgentConnectionModel> {
- this.session.modelRegistry.refresh();
- const model = this.session.modelRegistry.getAvailable().find((candidate) => {
+ const availableModels = await this.session.modelRegistry.refreshAvailableModels();
+ const model = availableModels.find((candidate) => {
return candidate.provider === provider && candidate.id === modelId;
});
if (!model) {
diff --git a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts b/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
index 8d1bb52e34..bf5c9eadaa 100644
--- a/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
+++ b/packages/coding-agent/src/modes/agents-view/agents-view-mode.ts
@@ -18,6 +18,7 @@ import {
import { APP_TITLE, appendRotatingLog, getAgentDir, getClientErrorLogPath, VERSION } from "../../config.js";
import type { AgentSessionRuntimeConfig } from "../../core/agent-session-config.js";
import { KeybindingsManager } from "../../core/keybindings.js";
+import type { ModelRegistry } from "../../core/model-registry.js";
import { findExactModelReferenceMatch } from "../../core/model-resolver.js";
import { resolvePrimeInferencePostLoginModelAction } from "../../core/prime-inference-model-selection.js";
import { SessionManager } from "../../core/session-manager.js";
@@ -223,6 +224,26 @@ export function formatAgentsViewStatusLine(text: string): string {
return text.replace(/\s+/g, " ").trim();
}
+export async function getAgentsViewModelArgumentCompletions(
+ prefix: string,
+ modelRegistry: Pick<ModelRegistry, "refreshAvailableModels">,
+): Promise<AutocompleteItem[] | null> {
+ const models = await modelRegistry.refreshAvailableModels();
+ if (models.length === 0) {
+ return null;
+ }
+ const items = models.map((model) => ({
+ id: model.id,
+ provider: model.provider,
+ label: `${model.provider}/${model.id}`,
+ }));
+ const filtered = fuzzyFilter(items, prefix, (item) => `${item.id} ${item.provider}`);
+ if (filtered.length === 0) {
+ return null;
+ }
+ return filtered.map((item) => ({ value: item.label, label: item.id, description: item.provider }));
+}
+
export function shouldReconnectAgentsViewDaemon(reason: DaemonClosingReason | undefined): boolean {
return reason !== "shutdown";
}
@@ -983,7 +1004,7 @@ class AgentsViewMode implements Component, Focusable {
// unique model id reference applies directly without the picker.
const match = findExactModelReferenceMatch(
searchTerm,
- this.options.uiServices.modelRegistry.getAvailable(),
+ await this.options.uiServices.modelRegistry.refreshAvailableModels(),
);
if (match) {
this.applyDefaultModel(match);
@@ -1013,7 +1034,7 @@ class AgentsViewMode implements Component, Focusable {
modelRegistry,
showStatus: (message) => this.setStatusMessage(message),
showError: (message) => this.setStatusMessage(message, { tone: "error" }),
- getAvailableModels: async () => modelRegistry.getAvailable(),
+ getAvailableModels: () => modelRegistry.refreshAvailableModels(),
onLoginCompleted: () => {
void this.maybeWarnAboutAnthropicSubscriptionAuth(this.getDefaultModelForNewAgents());
},
@@ -1056,9 +1077,10 @@ class AgentsViewMode implements Component, Focusable {
this.setStatusMessage(warning, { tone: "warning", sticky: true });
}
- private showConfigurationMenu(initialTab: ConfigurationMenuTab, initialModelSearch?: string): Promise<void> {
+ private async showConfigurationMenu(initialTab: ConfigurationMenuTab, initialModelSearch?: string): Promise<void> {
const modelRegistry = this.options.uiServices.modelRegistry;
const authFlows = this.createAuthFlows();
+ const availableModels = await modelRegistry.refreshAvailableModels();
return new Promise((resolve) => {
let handle: OverlayHandle | undefined;
let settled = false;
@@ -1095,7 +1117,7 @@ class AgentsViewMode implements Component, Focusable {
if (authResult.status !== "success" || tab === "mcp-connections") return;
await this.applyPrimeInferenceFallbackAfterLogin(authResult);
- menu.updateModels(this.getDefaultModelForNewAgents(), modelRegistry.getAvailable());
+ menu.updateModels(this.getDefaultModelForNewAgents(), await modelRegistry.refreshAvailableModels());
menu.setActiveTab("models");
})
.catch((error) => {
@@ -1112,7 +1134,7 @@ class AgentsViewMode implements Component, Focusable {
modelRegistry,
currentModel: this.getDefaultModelForNewAgents(),
scopedModels: [],
- availableModels: modelRegistry.getAvailable(),
+ availableModels,
recentModels: this.options.uiServices.settingsManager.getRecentModels(),
initialModelSearch,
getRows: () => this.ui.terminal.rows,
@@ -1260,22 +1282,8 @@ class AgentsViewMode implements Component, Focusable {
}));
const modelCommand = commands.find((command) => command.name === "model");
if (modelCommand) {
- modelCommand.getArgumentCompletions = (prefix: string): AutocompleteItem[] | null => {
- const models = this.options.uiServices.modelRegistry.getAvailable();
- if (models.length === 0) {
- return null;
- }
- const items = models.map((model) => ({
- id: model.id,
- provider: model.provider,
- label: `${model.provider}/${model.id}`,
- }));
- const filtered = fuzzyFilter(items, prefix, (item) => `${item.id} ${item.provider}`);
- if (filtered.length === 0) {
- return null;
- }
- return filtered.map((item) => ({ value: item.label, label: item.id, description: item.provider }));
- };
+ modelCommand.getArgumentCompletions = (prefix: string) =>
+ getAgentsViewModelArgumentCompletions(prefix, this.options.uiServices.modelRegistry);
}
return new CombinedAutocompleteProvider(commands, this.options.uiServices.getInitialCwd(), null);
}
diff --git a/packages/coding-agent/src/modes/daemon/daemon-mode.ts b/packages/coding-agent/src/modes/daemon/daemon-mode.ts
index 5c9dda98bb..d4dd658773 100644
--- a/packages/coding-agent/src/modes/daemon/daemon-mode.ts
+++ b/packages/coding-agent/src/modes/daemon/daemon-mode.ts
@@ -2398,9 +2398,8 @@ export class AgentDaemon {
case "get_available_models": {
const state = this.getSessionState(command.activeSessionId);
- state.runtime.session.modelRegistry.refresh();
return success(command.id, "get_available_models", {
- models: state.runtime.session.modelRegistry.getAvailable(),
+ models: await state.runtime.session.modelRegistry.refreshAvailableModels(),
});
}
@@ -2478,8 +2477,8 @@ export class AgentDaemon {
case "set_model": {
const state = this.getSessionState(command.activeSessionId);
const session = state.runtime.session;
- session.modelRegistry.refresh();
- const model = session.modelRegistry.getAvailable().find((candidate) => {
+ const availableModels = await session.modelRegistry.refreshAvailableModels();
+ const model = availableModels.find((candidate) => {
return candidate.provider === command.provider && candidate.id === command.modelId;
});
if (!model) {
diff --git a/packages/coding-agent/src/modes/rpc/rpc-mode.ts b/packages/coding-agent/src/modes/rpc/rpc-mode.ts
index 135c8e2b8e..ff7e93a336 100644
--- a/packages/coding-agent/src/modes/rpc/rpc-mode.ts
+++ b/packages/coding-agent/src/modes/rpc/rpc-mode.ts
@@ -452,7 +452,7 @@ export async function runRpcMode(runtimeHost: AgentSessionRuntime): Promise<neve
// =================================================================
case "set_model": {
- const models = await session.modelRegistry.getAvailable();
+ const models = await session.modelRegistry.refreshAvailableModels();
const model = models.find((m) => m.provider === command.provider && m.id === command.modelId);
if (!model) {
return error(id, "set_model", `Model not found: ${command.provider}/${command.modelId}`);
@@ -470,7 +470,7 @@ export async function runRpcMode(runtimeHost: AgentSessionRuntime): Promise<neve
}
case "get_available_models": {
- const models = await session.modelRegistry.getAvailable();
+ const models = await session.modelRegistry.refreshAvailableModels();
return success(id, "get_available_models", { models });
}
diff --git a/packages/coding-agent/test/daemon-mode.test.ts b/packages/coding-agent/test/daemon-mode.test.ts
index 8ebef4bc3e..35a1221f64 100644
--- a/packages/coding-agent/test/daemon-mode.test.ts
+++ b/packages/coding-agent/test/daemon-mode.test.ts
@@ -3902,8 +3902,7 @@ describe("daemon mode helpers", () => {
runtime: ActiveSessionState["runtime"] & {
session: {
modelRegistry: {
- refresh(): void;
- getAvailable(): unknown[];
+ refreshAvailableModels(): Promise<unknown[]>;
};
isStreaming: boolean;
isCompacting: boolean;
@@ -3913,8 +3912,7 @@ describe("daemon mode helpers", () => {
};
state.runtime.session = {
modelRegistry: {
- refresh: vi.fn(),
- getAvailable: vi.fn(() => [model]),
+ refreshAvailableModels: vi.fn(async () => [model]),
},
isStreaming: true,
isCompacting: false,
@@ -3961,8 +3959,7 @@ describe("daemon mode helpers", () => {
runtime: ActiveSessionState["runtime"] & {
session: {
modelRegistry: {
- refresh(): void;
- getAvailable(): unknown[];
+ refreshAvailableModels(): Promise<unknown[]>;
};
isStreaming: boolean;
isCompacting: boolean;
@@ -3972,8 +3969,7 @@ describe("daemon mode helpers", () => {
};
state.runtime.session = {
modelRegistry: {
- refresh: vi.fn(),
- getAvailable: vi.fn(() => [model]),
+ refreshAvailableModels: vi.fn(async () => [model]),
},
isStreaming: false,
isCompacting: false,
diff --git a/packages/coding-agent/test/model-resolver.test.ts b/packages/coding-agent/test/model-resolver.test.ts
index 511260d430..d12f068a47 100644
--- a/packages/coding-agent/test/model-resolver.test.ts
+++ b/packages/coding-agent/test/model-resolver.test.ts
@@ -459,7 +459,7 @@ describe("default model selection", () => {
test("findInitialModel uses medium as the built-in default thinking level", async () => {
const reasoningModel = mockModels[0];
const registry = {
- getAvailable: async () => [reasoningModel],
+ refreshAvailableModels: async () => [reasoningModel],
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
const result = await findInitialModel({
@@ -491,7 +491,7 @@ describe("default model selection", () => {
maxTokens: 101376,
};
const registry = {
- getAvailable: async () => [anthropicModel, primeModel],
+ refreshAvailableModels: async () => [anthropicModel, primeModel],
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
const result = await findInitialModel({
@@ -510,7 +510,7 @@ describe("default model selection", () => {
name: "Claude Opus 4.7",
};
const registry = {
- getAvailable: async () => [anthropicModel],
+ refreshAvailableModels: async () => [anthropicModel],
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
const result = await findInitialModel({
@@ -537,7 +537,7 @@ describe("default model selection", () => {
};
const registry = {
- getAvailable: async () => [aiGatewayModel],
+ refreshAvailableModels: async () => [aiGatewayModel],
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
const result = await findInitialModel({
@@ -568,7 +568,7 @@ describe("default model selection", () => {
find: (provider: string, modelId: string) =>
[savedDefault, primeModel].find((model) => model.provider === provider && model.id === modelId),
hasConfiguredAuth: (model: Model<"anthropic-messages">) => model.provider === "prime-inference",
- getAvailable: async () => [primeModel],
+ refreshAvailableModels: async () => [primeModel],
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
const result = await findInitialModel({
@@ -600,7 +600,7 @@ describe("default model selection", () => {
find: () => undefined,
getAll: () => [primeSnapshotModel],
hasConfiguredAuth: (model: Model<"anthropic-messages">) => model.provider === "prime-inference",
- getAvailable: async () => [primeSnapshotModel],
+ refreshAvailableModels: async () => [primeSnapshotModel],
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
const result = await findInitialModel({
@@ -632,7 +632,7 @@ describe("default model selection", () => {
find: () => undefined,
getAll: () => [...mockModels, primeSnapshotModel],
hasConfiguredAuth: (model: Model<"anthropic-messages">) => model.provider === "prime-inference",
- getAvailable: async () => [primeSnapshotModel],
+ refreshAvailableModels: async () => [primeSnapshotModel],
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
const result = await findInitialModel({
diff --git a/packages/coding-agent/test/suite/regressions/4645-internal-glm.test.ts b/packages/coding-agent/test/suite/regressions/4645-internal-glm.test.ts
new file mode 100644
index 0000000000..3da2dc3042
--- /dev/null
+++ b/packages/coding-agent/test/suite/regressions/4645-internal-glm.test.ts
@@ -0,0 +1,320 @@
+import { writeFileSync } from "node:fs";
+import { join } from "node:path";
+import { afterEach, describe, expect, test, vi } from "vitest";
+import { AuthStorage } from "../../../src/core/auth-storage.js";
+import { ModelRegistry } from "../../../src/core/model-registry.js";
+import { findInitialModel, restoreModelFromSession } from "../../../src/core/model-resolver.js";
+import { getAgentsViewModelArgumentCompletions } from "../../../src/modes/agents-view/agents-view-mode.js";
+import { createHarness, type Harness } from "../harness.js";
+
+describe("ENG-4645 internal GLM configuration", () => {
+ const harnesses: Harness[] = [];
+
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ for (const harness of harnesses.splice(0)) {
+ harness.cleanup();
+ }
+ });
+
+ test("shows the private route when the selected team's catalog authorizes it", async () => {
+ const harness = await createHarness({ withConfiguredAuth: false });
+ harnesses.push(harness);
+ const fetchMock = vi.fn(async () => {
+ return new Response(JSON.stringify({ data: [{ id: "internal/glm-5.2-fast" }] }), { status: 200 });
+ });
+ vi.stubGlobal("fetch", fetchMock);
+ const authStorage = AuthStorage.inMemory({
+ "prime-inference": {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "engineering-team", name: "Prime Engineering" },
+ },
+ });
+ const registry = ModelRegistry.inMemory(authStorage);
+
+ expect(registry.getAvailable().some((model) => model.id === "internal/glm-5.2-fast")).toBe(false);
+ const models = await registry.refreshAvailableModels();
+ const model = models.find((candidate) => candidate.id === "internal/glm-5.2-fast");
+
+ expect(model).toMatchObject({
+ name: "GLM 5.2 Fast",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ reasoning: true,
+ contextWindow: 400000,
+ maxTokens: 131072,
+ featured: true,
+ compat: {
+ supportsDeveloperRole: false,
+ maxTokensField: "max_tokens",
+ },
+ });
+ expect(fetchMock).toHaveBeenCalledWith("https://api.pinference.ai/api/v1/models", {
+ headers: {
+ Authorization: "Bearer prime-key",
+ "X-Prime-Team-ID": "engineering-team",
+ },
+ signal: expect.any(AbortSignal),
+ });
+ });
+
+ test("hides the private route when the selected team's catalog omits it", async () => {
+ const harness = await createHarness({ withConfiguredAuth: false });
+ harnesses.push(harness);
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async () => new Response(JSON.stringify({ data: [] }), { status: 200 })),
+ );
+ const authStorage = AuthStorage.inMemory({
+ "prime-inference": {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "other-team", name: "Other Team" },
+ },
+ });
+ const registry = ModelRegistry.inMemory(authStorage);
+
+ expect((await registry.refreshAvailableModels()).some((model) => model.id === "internal/glm-5.2-fast")).toBe(
+ false,
+ );
+ });
+
+ test("preserves authorization on transient failures only for the same team", async () => {
+ const harness = await createHarness({ withConfiguredAuth: false });
+ harnesses.push(harness);
+ const fetchMock = vi
+ .fn()
+ .mockResolvedValueOnce(
+ new Response(JSON.stringify({ data: [{ id: "internal/glm-5.2-fast" }] }), { status: 200 }),
+ )
+ .mockResolvedValue(new Response(null, { status: 503 }));
+ vi.stubGlobal("fetch", fetchMock);
+ const authStorage = AuthStorage.inMemory({
+ "prime-inference": {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "engineering-team", name: "Prime Engineering" },
+ },
+ });
+ const registry = ModelRegistry.inMemory(authStorage);
+
+ expect((await registry.refreshAvailableModels()).some((model) => model.id === "internal/glm-5.2-fast")).toBe(
+ true,
+ );
+ expect((await registry.refreshAvailableModels()).some((model) => model.id === "internal/glm-5.2-fast")).toBe(
+ true,
+ );
+
+ authStorage.set("prime-inference", {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "other-team", name: "Other Team" },
+ });
+ expect((await registry.refreshAvailableModels()).some((model) => model.id === "internal/glm-5.2-fast")).toBe(
+ false,
+ );
+ });
+
+ test("does not restore a private route that the selected team cannot access", async () => {
+ const harness = await createHarness({ withConfiguredAuth: false });
+ harnesses.push(harness);
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async () => new Response(JSON.stringify({ data: [] }), { status: 200 })),
+ );
+ const authStorage = AuthStorage.inMemory({
+ "prime-inference": {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "other-team", name: "Other Team" },
+ },
+ });
+ const registry = ModelRegistry.inMemory(authStorage);
+
+ const initial = await findInitialModel({
+ scopedModels: [],
+ isContinuing: false,
+ defaultProvider: "prime-inference",
+ defaultModelId: "internal/glm-5.2-fast",
+ modelRegistry: registry,
+ });
+ expect(initial.model?.id).not.toBe("internal/glm-5.2-fast");
+
+ const restored = await restoreModelFromSession(
+ "prime-inference",
+ "internal/glm-5.2-fast",
+ undefined,
+ false,
+ registry,
+ );
+ expect(restored.model?.id).not.toBe("internal/glm-5.2-fast");
+ expect(restored.fallbackMessage).toContain("model is not available");
+ });
+
+ test("selects an authorized private route from a saved default on cold start", async () => {
+ const harness = await createHarness({ withConfiguredAuth: false });
+ harnesses.push(harness);
+ const fetchMock = vi.fn(
+ async () => new Response(JSON.stringify({ data: [{ id: "internal/glm-5.2-fast" }] }), { status: 200 }),
+ );
+ vi.stubGlobal("fetch", fetchMock);
+ const authStorage = AuthStorage.inMemory({
+ "prime-inference": {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "engineering-team", name: "Prime Engineering" },
+ },
+ });
+ const registry = ModelRegistry.inMemory(authStorage);
+
+ const initial = await findInitialModel({
+ scopedModels: [],
+ isContinuing: false,
+ defaultProvider: "prime-inference",
+ defaultModelId: "internal/glm-5.2-fast",
+ modelRegistry: registry,
+ });
+
+ expect(initial.model?.id).toBe("internal/glm-5.2-fast");
+ expect(fetchMock).toHaveBeenCalledOnce();
+ });
+
+ test("refreshes private routes for agents view model autocomplete", async () => {
+ const harness = await createHarness({ withConfiguredAuth: false });
+ harnesses.push(harness);
+ const fetchMock = vi.fn(
+ async () => new Response(JSON.stringify({ data: [{ id: "internal/glm-5.2-fast" }] }), { status: 200 }),
+ );
+ vi.stubGlobal("fetch", fetchMock);
+ const authStorage = AuthStorage.inMemory({
+ "prime-inference": {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "engineering-team", name: "Prime Engineering" },
+ },
+ });
+ const registry = ModelRegistry.inMemory(authStorage);
+
+ const completions = await getAgentsViewModelArgumentCompletions("internal/glm", registry);
+
+ expect(completions).toContainEqual({
+ value: "prime-inference/internal/glm-5.2-fast",
+ label: "internal/glm-5.2-fast",
+ description: "prime-inference",
+ });
+ expect(fetchMock).toHaveBeenCalledOnce();
+ });
+
+ test("refreshes private routes before cycling models", async () => {
+ const harness = await createHarness();
+ harnesses.push(harness);
+ const currentModel = harness.session.model;
+ const privateModel = harness.session.modelRegistry.find("prime-inference", "internal/glm-5.2-fast");
+ expect(currentModel).toBeDefined();
+ expect(privateModel).toBeDefined();
+ if (!currentModel || !privateModel) {
+ throw new Error("Expected current and private models");
+ }
+ const refreshSpy = vi
+ .spyOn(harness.session.modelRegistry, "refreshAvailableModels")
+ .mockResolvedValue([currentModel, privateModel]);
+
+ const result = await harness.session.cycleModel();
+
+ expect(refreshSpy).toHaveBeenCalledOnce();
+ expect(result?.model.id).toBe("internal/glm-5.2-fast");
+ });
+
+ test("rejects unauthorized direct and scoped model switches", async () => {
+ const harness = await createHarness();
+ harnesses.push(harness);
+ harness.authStorage.set("prime-inference", {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "other-team", name: "Other Team" },
+ });
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async () => new Response(JSON.stringify({ data: [] }), { status: 200 })),
+ );
+ const currentModel = harness.session.model;
+ const privateModel = harness.session.modelRegistry.find("prime-inference", "internal/glm-5.2-fast");
+ expect(currentModel).toBeDefined();
+ expect(privateModel).toBeDefined();
+ if (!currentModel || !privateModel) {
+ throw new Error("Expected current and private models");
+ }
+
+ await expect(harness.session.setModel(privateModel)).rejects.toThrow("not available for the current Prime team");
+ harness.session.setScopedModels([{ model: currentModel }, { model: privateModel }]);
+
+ expect(await harness.session.cycleModel()).toBeUndefined();
+ expect(harness.session.model).toBe(currentModel);
+ });
+
+ test("loads the private route explicitly without inheriting Z.ai compatibility", async () => {
+ const harness = await createHarness({ withConfiguredAuth: false });
+ harnesses.push(harness);
+ const modelsJsonPath = join(harness.tempDir, "models.json");
+ writeFileSync(
+ modelsJsonPath,
+ JSON.stringify({
+ providers: {
+ "prime-inference": {
+ baseUrl: "https://api.pinference.ai/api/v1",
+ api: "openai-completions",
+ compat: {
+ supportsDeveloperRole: false,
+ maxTokensField: "max_tokens",
+ },
+ models: [
+ {
+ id: "internal/glm-5.2-fast",
+ name: "GLM 5.2 Fast",
+ reasoning: true,
+ contextWindow: 400000,
+ maxTokens: 131072,
+ },
+ ],
+ },
+ },
+ }),
+ );
+ const authStorage = AuthStorage.inMemory({
+ "prime-inference": {
+ type: "api_key",
+ key: "prime-key",
+ primeTeam: { teamId: "engineering-team", name: "Prime Engineering" },
+ },
+ });
+ const registry = ModelRegistry.create(authStorage, modelsJsonPath);
+
+ expect(registry.getError()).toBeUndefined();
+ expect(registry.getAvailable().some((model) => model.id === "internal/glm-5.2-fast")).toBe(true);
+ const model = registry.find("prime-inference", "internal/glm-5.2-fast");
+ expect(model).toMatchObject({
+ id: "internal/glm-5.2-fast",
+ name: "GLM 5.2 Fast",
+ api: "openai-completions",
+ provider: "prime-inference",
+ baseUrl: "https://api.pinference.ai/api/v1",
+ reasoning: true,
+ contextWindow: 400000,
+ maxTokens: 131072,
+ compat: {
+ supportsDeveloperRole: false,
+ maxTokensField: "max_tokens",
+ },
+ });
+ expect(model?.compat).not.toMatchObject({ thinkingFormat: "zai" });
+ expect(model?.compat).not.toMatchObject({ supportsReasoningEffort: false });
+
+ expect(await registry.getApiKeyAndHeaders(model!)).toEqual({
+ ok: true,
+ apiKey: "prime-key",
+ headers: { "X-Prime-Team-ID": "engineering-team" },
+ });
+ });
+});