Comfy-Org/ComfyUI · error · ValueError

Resolution {size} is only supported by GPT Image 2 model

Error message

Resolution {size} is only supported by GPT Image 2 model

What it means

Client-side ValueError raised when the model is gpt-image-1 or gpt-image-1.5 and size is not one of the four supported presets ('auto','1024x1024','1024x1536','1536x1024'). Older GPT Image models only accept fixed resolutions; arbitrary sizes are a GPT Image 2 capability, so the node blocks the combination before the request.

Source

Thrown at comfy_api_nodes/nodes_openai.py:558

                raise ValueError("Custom resolution is only supported by GPT Image 2 model")
            if custom_width % 16 != 0 or custom_height % 16 != 0:
                raise ValueError(f"Custom width and height must be multiples of 16, got {custom_width}x{custom_height}")
            if max(custom_width, custom_height) > 3840:
                raise ValueError(f"Custom resolution max edge must be <= 3840, got {custom_width}x{custom_height}")
            ratio = max(custom_width, custom_height) / min(custom_width, custom_height)
            if ratio > 3:
                raise ValueError(
                    f"Custom resolution aspect ratio must not exceed 3:1, got {custom_width}x{custom_height}"
                )
            total_pixels = custom_width * custom_height
            if not 655_360 <= total_pixels <= 8_294_400:
                raise ValueError(
                    f"Custom resolution total pixels must be between 655,360 and 8,294,400, got {total_pixels}"
                )
            size = f"{custom_width}x{custom_height}"
        elif model in ("gpt-image-1", "gpt-image-1.5"):
            if size not in ("auto", "1024x1024", "1024x1536", "1536x1024"):
                raise ValueError(f"Resolution {size} is only supported by GPT Image 2 model")

        if model == "gpt-image-2":
            if background == "transparent":
                raise ValueError("Transparent background is not supported for GPT Image 2 model")
        elif model not in ("gpt-image-1", "gpt-image-1.5"):
            raise ValueError(f"Unknown model: {model}")

        if image is not None:
            files = []
            batch_size = image.shape[0]
            for i in range(batch_size):
                single_image = image[i : i + 1]
                scaled_image = downscale_image_tensor(single_image, total_pixels=2048 * 2048).squeeze()

                image_np = (scaled_image.numpy() * 255).astype(np.uint8)
                img = Image.fromarray(image_np)
                img_byte_arr = BytesIO()
                img.save(img_byte_arr, format="PNG")

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Set size to one of auto/1024x1024/1024x1536/1536x1024 for gpt-image-1/1.5
  2. Or switch the model to gpt-image-2 and pass Custom dimensions that satisfy its constraints
  3. Fix stale workflow JSON so the size widget value matches the selected model

Example fix

// before
model="gpt-image-1", size="512x512"
// after
model="gpt-image-1", size="1024x1024"
// or use gpt-image-2 with valid Custom dimensions
Defensive patterns

Strategy: validation

Validate before calling

GPT_IMAGE1_SIZES = {"auto", "1024x1024", "1024x1536", "1536x1024"}
if model in ("gpt-image-1", "gpt-image-1.5"):
    assert size in GPT_IMAGE1_SIZES, f"{size} not valid for {model}"

Type guard

def size_valid_for_model(model: str, size: str) -> bool:
    if model in ("gpt-image-1", "gpt-image-1.5"):
        return size in {"auto", "1024x1024", "1024x1536", "1536x1024"}
    return True

Prevention

When it happens

Trigger: model='gpt-image-1' with size='1536x1536', '512x512', 'Custom', or any string outside the allowlist.

Common situations: Saved workflows from other providers (e.g. Dall-E sizes like 512x512) reused with gpt-image-1; hand-edited workflow JSON with a size string; switching models without updating the size widget.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/7520e3ab83788674. Report an issue: GitHub.