This commit is contained in:
reanon
2025-11-14 07:36:10 +01:00
parent 2a30407542
commit d88bb23fc2
9 changed files with 23 additions and 6 deletions
+2
View File
@@ -42,6 +42,7 @@ const MODEL_FAMILY_FRIENDLY_NAME: { [f in ModelFamily]: string } = {
"gpt41-mini": "GPT-4.1 Mini",
"gpt41-nano": "GPT-4.1 Nano",
gpt5: "GPT-5",
gpt51: "GPT-5.1",
"gpt5-mini": "GPT-5 Mini",
"gpt5-nano": "GPT-5 Nano",
"gpt5-pro": "GPT-5 Pro",
@@ -84,6 +85,7 @@ const MODEL_FAMILY_FRIENDLY_NAME: { [f in ModelFamily]: string } = {
"azure-gpt41-mini": "Azure GPT-4.1 Mini",
"azure-gpt41-nano": "Azure GPT-4.1 Nano",
"azure-gpt5": "Azure GPT-5",
"azure-gpt51": "Azure GPT-5.1",
"azure-gpt5-mini": "Azure GPT-5 Mini",
"azure-gpt5-nano": "Azure GPT-5 Nano",
"azure-gpt5-pro": "GPT-5 Pro (Azure)",
@@ -67,6 +67,12 @@ export const validateContextSize: RequestPreprocessor = async (req) => {
modelMax = 1000000;
} else if (model.match(/^gpt-4\.1-nano(-\d{4}-\d{2}-\d{2})?$/)) {
modelMax = 1000000;
} else if (model.match(/^gpt-5\.1(-\d{4}-\d{2}-\d{2})?$/)) {
modelMax = 400000;
} else if (model.match(/^gpt-5\.1-mini(-\d{4}-\d{2}-\d{2})?$/)) {
modelMax = 400000;
} else if (model.match(/^gpt-5\.1-nano(-\d{4}-\d{2}-\d{2})?$/)) {
modelMax = 400000;
} else if (model.match(/^gpt-5(-\d{4}-\d{2}-\d{2})?$/)) {
modelMax = 400000;
} else if (model.match(/^gpt-5-mini(-\d{4}-\d{2}-\d{2})?$/)) {
+2 -2
View File
@@ -487,13 +487,13 @@ function fixupMaxTokens(req: Request) {
}
}
// GPT-5, GPT-5-mini, and GPT-5-nano don't support certain parameters
// GPT-5, GPT-5.1, GPT-5-mini, and GPT-5-nano don't support certain parameters
// Remove them if present to prevent API errors
function filterGPT5UnsupportedParams(req: Request) {
const model = req.body.model;
// Only apply filtering to these specific models (gpt5-chat-latest supports all params)
const restrictedModels = /^gpt-5(-mini|-nano)?(-\d{4}-\d{2}-\d{2})?$/;
const restrictedModels = /^gpt-5(\\.1)?(-mini|-nano)?(-\d{4}-\d{2}-\d{2})?$/;
if (!restrictedModels.test(model)) {
return; // Not a restricted model, no filtering needed
+2
View File
@@ -53,6 +53,7 @@ const MODEL_FAMILY_ORDER: ModelFamily[] = [
"gpt41-nano",
"gpt45",
"gpt5",
"gpt51",
"gpt5-mini",
"gpt5-nano",
"gpt5-chat-latest",
@@ -78,6 +79,7 @@ const MODEL_FAMILY_ORDER: ModelFamily[] = [
"azure-gpt41-nano",
"azure-gpt45",
"azure-gpt5",
"azure-gpt51",
"azure-gpt5-mini",
"azure-gpt5-nano",
"azure-gpt5-chat-latest",
+1 -1
View File
@@ -20,7 +20,7 @@ export const OpenAIV1ResponsesSchema = z.object({
frequency_penalty: z.number().min(-2).max(2).optional(),
user: z.string().optional(),
tools: z.array(z.any()).optional(),
reasoning_effort: z.enum(["low", "medium", "high"]).optional(),
reasoning_effort: z.enum(["none", "low", "medium", "high"]).optional(),
});
// Allow transforming from OpenAI Chat to Responses format
+1 -1
View File
@@ -77,7 +77,7 @@ export const OpenAIV1ChatCompletionSchema = z
functions: z.array(z.any()).optional(),
tool_choice: z.any().optional(),
function_choice: z.any().optional(),
reasoning_effort: z.enum(["minimal", "low", "medium", "high"]).optional(),
reasoning_effort: z.enum(["none", "minimal", "low", "medium", "high"]).optional(),
verbosity: z.enum(["low", "medium", "high"]).optional(),
response_format: z.any(),
})
+2 -2
View File
@@ -146,8 +146,8 @@ export class OpenAIKeyProvider implements KeyProvider<OpenAIKey> {
const excludeTrials = model === "text-embedding-ada-002";
const isGptImageRequest = neededFamily === "gpt-image";
// GPT-5 models (gpt-5, gpt-5-mini, gpt-5-nano) require verified keys for streaming
const isGpt5Model = /^gpt-5(-mini|-nano)?(-\d{4}-\d{2}-\d{2})?$/.test(model);
// GPT-5 models (gpt-5, gpt-5.1, gpt-5-mini, gpt-5-nano) require verified keys for streaming
const isGpt5Model = /^gpt-5(\\.1)?(-mini|-nano)?(-\d{4}-\d{2}-\d{2})?$/.test(model);
const isO1Model = /^o1(-mini|-preview)?(-\d{4}-\d{2}-\d{2})?$/.test(model);
const isO3Model = /^o3(-mini)?(-\d{4}-\d{2}-\d{2})?$/.test(model);
const isO4MiniModel = /^o4-mini(-\d{4}-\d{2}-\d{2})?$/.test(model);
+5
View File
@@ -33,6 +33,7 @@ export type OpenAIModelFamily =
| "gpt41-nano"
| "gpt45"
| "gpt5"
| "gpt51"
| "gpt5-mini"
| "gpt5-nano"
| "gpt5-chat-latest"
@@ -102,6 +103,7 @@ export const MODEL_FAMILIES = (<A extends readonly ModelFamily[]>(
"gpt41-mini",
"gpt41-nano",
"gpt5",
"gpt51",
"gpt5-mini",
"gpt5-nano",
"gpt5-chat-latest",
@@ -196,6 +198,7 @@ export const MODEL_FAMILY_SERVICE: {
"gpt41-mini": "openai",
"gpt41-nano": "openai",
gpt5: "openai",
gpt51: "openai",
"gpt5-mini": "openai",
"gpt5-nano": "openai",
"gpt5-chat-latest": "openai",
@@ -230,6 +233,7 @@ export const MODEL_FAMILY_SERVICE: {
"azure-gpt41-mini": "azure",
"azure-gpt41-nano": "azure",
"azure-gpt5": "azure",
"azure-gpt51": "azure",
"azure-gpt5-mini": "azure",
"azure-gpt5-nano": "azure",
"azure-gpt5-chat-latest": "azure",
@@ -257,6 +261,7 @@ export const IMAGE_GEN_MODELS: ModelFamily[] = ["dall-e", "azure-dall-e", "gpt-i
export const OPENAI_MODEL_FAMILY_MAP: { [regex: string]: OpenAIModelFamily } = {
"^gpt-image(-\\d+)?(-preview)?(-\\d{4}-\\d{2}-\\d{2})?$": "gpt-image",
"^gpt-5\\.1(-\\d{4}-\\d{2}-\\d{2})?$": "gpt51",
"^gpt-5(-\\d{4}-\\d{2}-\\d{2})?$": "gpt5",
"^gpt-5-mini(-\\d{4}-\\d{2}-\\d{2})?$": "gpt5-mini",
"^gpt-5-nano(-\\d{4}-\\d{2}-\\d{2})?$": "gpt5-nano",
+2
View File
@@ -14,6 +14,8 @@ const MODEL_PRICING: Record<ModelFamily, { input: number; output: number } | und
"azure-gpt41-nano": { input: 0.10, output: 0.40 },
"gpt5": { input: 1.25, output: 10.00 },
"azure-gpt5": { input: 1.25, output: 10.00 },
"gpt51": { input: 1.25, output: 10.00 },
"azure-gpt51": { input: 1.25, output: 10.00 },
"gpt5-mini": { input: 0.25, output: 2.00 },
"azure-gpt5-mini": { input: 0.25, output: 2.00 },
"gpt5-nano": { input: 0.05, output: 0.40 },