feat(codex): add review model quota support (#836)

This commit is contained in:
Rezky Hamid
2026-05-03 14:57:33 +07:00
committed by GitHub
parent 14ff538f2e
commit a463ee00ff
8 changed files with 153 additions and 34 deletions
+39 -2
View File
@@ -5,6 +5,27 @@ import { buildTtsProviderModels } from "./ttsModels.js";
// Key = alias (cc, cx, gc, qw, if, ag, gh for OAuth; id for API Key)
// Field "provider" for special cases (e.g. AntiGravity models that call different backends)
const CODEX_REVIEW_SUFFIX = "-review";
function withCodexReviewModels(models) {
return models.flatMap((model) => {
if ((model.type || "llm") !== "llm" || model.id.endsWith(CODEX_REVIEW_SUFFIX)) {
return [model];
}
return [
model,
{
...model,
id: `${model.id}${CODEX_REVIEW_SUFFIX}`,
name: `${model.name} Review`,
upstreamModelId: model.upstreamModelId || model.id,
quotaFamily: "review",
},
];
});
}
export const PROVIDER_MODELS = {
// OAuth Providers (using alias)
cc: [ // Claude Code
@@ -15,7 +36,7 @@ export const PROVIDER_MODELS = {
{ id: "claude-sonnet-4-5-20250929", name: "Claude 4.5 Sonnet" },
{ id: "claude-haiku-4-5-20251001", name: "Claude 4.5 Haiku" },
],
cx: [ // OpenAI Codex
cx: withCodexReviewModels([ // OpenAI Codex
{ id: "gpt-5.5", name: "GPT 5.5" },
{ id: "gpt-5.4", name: "GPT 5.4" },
// GPT 5.3 Codex - all thinking levels
@@ -40,7 +61,7 @@ export const PROVIDER_MODELS = {
{ id: "gpt-5.4-image", name: "GPT 5.4 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
{ id: "gpt-5.3-image", name: "GPT 5.3 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
{ id: "gpt-5.2-image", name: "GPT 5.2 Image", type: "image", capabilities: ["text2img", "edit"], params: ["size", "quality", "background", "image_detail", "output_format"] },
],
]),
gc: [ // Gemini CLI
{ id: "gemini-3-flash-preview", name: "Gemini 3 Flash Preview" },
{ id: "gemini-3-pro-preview", name: "Gemini 3 Pro Preview" },
@@ -568,6 +589,22 @@ export function getModelTargetFormat(aliasOrId, modelId) {
return found?.targetFormat || null;
}
export function getModelUpstreamId(aliasOrId, modelId) {
const models = PROVIDER_MODELS[aliasOrId];
const found = models?.find(m => m.id === modelId);
if (found?.upstreamModelId) return found.upstreamModelId;
if (aliasOrId === "cx" && typeof modelId === "string" && modelId.endsWith(CODEX_REVIEW_SUFFIX)) {
return modelId.slice(0, -CODEX_REVIEW_SUFFIX.length);
}
return modelId;
}
export function getModelQuotaFamily(aliasOrId, modelId) {
const models = PROVIDER_MODELS[aliasOrId];
const found = models?.find(m => m.id === modelId);
return found?.quotaFamily || "normal";
}
// OAuth providers that use short aliases (everything else: alias = id)
const OAUTH_ALIASES = {
claude: "cc",