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
@@ -36,6 +36,27 @@ const parseGeminiCliModels = (data) => {
return [];
};
const appendCodexReviewModels = (models) => models.flatMap((model) => {
const id = model?.id || model?.slug || model?.model || model?.name;
if (!id) return [];
const name = model?.display_name || model?.displayName || model?.name || id;
const normalized = { ...model, id, name };
const isChatModel = (model?.type || "llm") !== "image" && !id.toLowerCase().includes("embed");
if (!isChatModel || id.endsWith("-review")) return [normalized];
return [
normalized,
{
...normalized,
id: `${id}-review`,
name: `${name} Review`,
upstreamModelId: id,
quotaFamily: "review",
},
];
});
const parseCodexModels = (data) => appendCodexReviewModels(parseOpenAIStyleModels(data));
const createOpenAIModelsConfig = (url) => ({
url,
method: "GET",
@@ -84,6 +105,14 @@ const PROVIDER_MODELS_CONFIG = {
authPrefix: "Bearer ",
parseResponse: (data) => data.data || []
},
codex: {
url: "https://chatgpt.com/backend-api/codex/models?client_version=1.0.0",
method: "GET",
headers: { "Content-Type": "application/json", "Accept": "application/json" },
authHeader: "Authorization",
authPrefix: "Bearer ",
parseResponse: parseCodexModels
},
antigravity: {
url: "https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal:models",
method: "POST",
+2 -2
View File
@@ -415,7 +415,7 @@ export async function createProviderConnection(data) {
const optionalFields = [
"displayName", "email", "globalPriority", "defaultModel",
"accessToken", "refreshToken", "expiresAt", "tokenType",
"scope", "idToken", "projectId", "apiKey", "testStatus",
"scope", "projectId", "apiKey", "testStatus",
"lastTested", "lastError", "lastErrorAt", "rateLimitedUntil", "expiresIn", "errorCode",
"consecutiveUseCount"
];
@@ -681,7 +681,7 @@ export async function cleanupProviderConnections() {
const fieldsToCheck = [
"displayName", "email", "globalPriority", "defaultModel",
"accessToken", "refreshToken", "expiresAt", "tokenType",
"scope", "idToken", "projectId", "apiKey", "testStatus",
"scope", "projectId", "apiKey", "testStatus",
"lastTested", "lastError", "lastErrorAt", "rateLimitedUntil", "expiresIn",
"consecutiveUseCount"
];
-1
View File
@@ -172,7 +172,6 @@ const PROVIDERS = {
const mapped = {
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token,
idToken: tokens.id_token,
expiresIn: tokens.expires_in,
};
if (info.email) mapped.email = info.email;
-1
View File
@@ -53,7 +53,6 @@ export class CodexService extends OAuthService {
body: JSON.stringify({
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token,
idToken: tokens.id_token,
expiresIn: tokens.expires_in,
}),
});
+3 -1
View File
@@ -8,7 +8,9 @@ export {
getModelTargetFormat,
getModelStrip,
PROVIDER_ID_TO_ALIAS,
getModelsByProviderId
getModelsByProviderId,
getModelUpstreamId,
getModelQuotaFamily
} from "open-sse/config/providerModels.js";
import { AI_PROVIDERS, isOpenAICompatibleProvider } from "./providers.js";