{"record":{"id":"be8bf5089d892197","repo":"Comfy-Org/ComfyUI","slug":"custom-resolution-is-only-supported-by-gpt-image-2","errorCode":null,"errorMessage":"Custom resolution is only supported by GPT Image 2 model","messagePattern":"Custom resolution is only supported by GPT Image 2 model","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_openai.py","lineNumber":540,"sourceCode":"        seed: int = 0,\n        quality: str = \"low\",\n        background: str = \"opaque\",\n        image: Input.Image | None = None,\n        mask: Input.Image | None = None,\n        n: int = 1,\n        size: str = \"1024x1024\",\n        custom_width: int = 1024,\n        custom_height: int = 1024,\n        model: str = \"gpt-image-1\",\n    ) -> IO.NodeOutput:\n        validate_string(prompt, strip_whitespace=False)\n\n        if mask is not None and image is None:\n            raise ValueError(\"Cannot use a mask without an input image\")\n\n        if size == \"Custom\":\n            if model != \"gpt-image-2\":\n                raise ValueError(\"Custom resolution is only supported by GPT Image 2 model\")\n            if custom_width % 16 != 0 or custom_height % 16 != 0:\n                raise ValueError(f\"Custom width and height must be multiples of 16, got {custom_width}x{custom_height}\")\n            if max(custom_width, custom_height) > 3840:\n                raise ValueError(f\"Custom resolution max edge must be <= 3840, got {custom_width}x{custom_height}\")\n            ratio = max(custom_width, custom_height) / min(custom_width, custom_height)\n            if ratio > 3:\n                raise ValueError(\n                    f\"Custom resolution aspect ratio must not exceed 3:1, got {custom_width}x{custom_height}\"\n                )\n            total_pixels = custom_width * custom_height\n            if not 655_360 <= total_pixels <= 8_294_400:\n                raise ValueError(\n                    f\"Custom resolution total pixels must be between 655,360 and 8,294,400, got {total_pixels}\"\n                )\n            size = f\"{custom_width}x{custom_height}\"\n        elif model in (\"gpt-image-1\", \"gpt-image-1.5\"):\n            if size not in (\"auto\", \"1024x1024\", \"1024x1536\", \"1536x1024\"):\n                raise ValueError(f\"Resolution {size} is only supported by GPT Image 2 model\")","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_openai.py#L522-L558","documentation":"Client-side ValueError from the OpenAI image node: the size selector is set to 'Custom' but the chosen model is not gpt-image-2. Only GPT Image 2 accepts arbitrary custom_width/custom_height; gpt-image-1/1.5 are restricted to fixed sizes, so the node refuses the combination before the request.","triggerScenarios":"Setting size='Custom' with model='gpt-image-1' or 'gpt-image-1.5' (the default model is gpt-image-1, so merely switching size to Custom triggers it).","commonSituations":"Default model left unchanged while the user picks Custom resolution; workflows built for gpt-image-2 run after the model dropdown was switched back; stale saved workflows after a model rename.","solutions":["Switch the model input to gpt-image-2 to use Custom resolution","Or pick one of the preset sizes (auto/1024x1024/1024x1536/1536x1024) for gpt-image-1/1.5","Fix stale workflow JSON so size and model widgets are consistent"],"exampleFix":"// before\nmodel=\"gpt-image-1\", size=\"Custom\", custom_width=1280, custom_height=768\n// after\nmodel=\"gpt-image-2\", size=\"Custom\", custom_width=1280, custom_height=768","handlingStrategy":"validation","validationCode":"if size == \"Custom\":\n    assert model == \"gpt-image-2\", \"Custom size requires gpt-image-2\"","typeGuard":"def supports_custom_size(model: str) -> bool:\n    return model == \"gpt-image-2\"","tryCatchPattern":null,"preventionTips":["Remember the default model is gpt-image-1 - change it whenever you pick Custom","Keep model/size pairs consistent in saved workflow templates","Prefer preset sizes unless Custom is genuinely needed"],"tags":["openai","gpt-image","resolution","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}