Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
📐 fix: Accept Custom WIDTHxHEIGHT Sizes in OpenAI Image Tools (#15904)
Danny Avila3c39ea51913b
diff --git a/packages/api/src/tools/toolkits/oai.spec.ts b/packages/api/src/tools/toolkits/oai.spec.tsnew file mode 100644index 0000000000..e82975d422--- /dev/null+++ b/packages/api/src/tools/toolkits/oai.spec.ts@@ -0,0 +1,36 @@+import { oaiToolkit, IMAGE_SIZE_PATTERN } from './oai';++const sizeSchemas = [+ ['image_gen_oai', oaiToolkit.image_gen_oai.schema.properties?.size],+ ['image_edit_oai', oaiToolkit.image_edit_oai.schema.properties?.size],+] as const;++describe('OpenAI image toolkit size schema', () => {+ const pattern = new RegExp(IMAGE_SIZE_PATTERN);++ it.each(sizeSchemas)('%s accepts any WIDTHxHEIGHT instead of a fixed list', (_name, size) => {+ expect(size?.enum).toBeUndefined();+ expect(size?.pattern).toBe(IMAGE_SIZE_PATTERN);+ });++ it.each([+ 'auto',+ '8x8',+ '100000x100000',+ '1024x1024',+ '1536x1024',+ '256x256',+ '2048x1152',+ '3840x2160',+ '2160x3840',+ ])('accepts %s', (value) => {+ expect(pattern.test(value)).toBe(true);+ });++ it.each(['', '4K', '3840', '3840X2160', '3840 x 2160', '0x1024', '1024x0', 'auto1024x1024'])(+ 'rejects %s',+ (value) => {+ expect(pattern.test(value)).toBe(false);+ },+ );+});diff --git a/packages/api/src/tools/toolkits/oai.ts b/packages/api/src/tools/toolkits/oai.tsindex 33d5375572..19fd2eec54 100644--- a/packages/api/src/tools/toolkits/oai.ts+++ b/packages/api/src/tools/toolkits/oai.ts@@ -67,6 +67,9 @@ const getImageEditPromptDescription = () => {return process.env.IMAGE_EDIT_OAI_PROMPT_DESCRIPTION || DEFAULT_IMAGE_EDIT_PROMPT_DESCRIPTION;};+/** `auto` or `WIDTHxHEIGHT`; the image API enforces which dimensions the configured model supports. */+export const IMAGE_SIZE_PATTERN = '^(auto|[1-9][0-9]*x[1-9][0-9]*)$';+const imageGenOaiJsonSchema: ExtendedJsonSchema = {type: 'object',properties: {@@ -88,9 +91,9 @@ const imageGenOaiJsonSchema: ExtendedJsonSchema = {},size: {type: 'string',- enum: ['auto', '1024x1024', '1536x1024', '1024x1536'],+ pattern: IMAGE_SIZE_PATTERN,description:- 'The size of the generated image. One of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default).',+ 'The size of the generated image as WIDTHxHEIGHT in pixels, or auto (default). Common sizes: 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait). Models that support custom dimensions accept others, e.g. 2048x2048 or 3840x2160; the image API rejects sizes the configured model does not support.',},},required: ['prompt'],@@ -123,9 +126,9 @@ Guidelines:},size: {type: 'string',- enum: ['auto', '1024x1024', '1536x1024', '1024x1536', '256x256', '512x512'],+ pattern: IMAGE_SIZE_PATTERN,description:- 'The size of the generated images. For gpt-image-1: auto (default), 1024x1024, 1536x1024, 1024x1536. For dall-e-2: 256x256, 512x512, 1024x1024.',+ 'The size of the generated images as WIDTHxHEIGHT in pixels, or auto (default). Common sizes: 1024x1024, 1536x1024, 1024x1536; dall-e-2 uses 256x256, 512x512 or 1024x1024. Models that support custom dimensions accept others, e.g. 3840x2160.',},},required: ['image_ids', 'prompt'],