Comfy-Org/ComfyUI · error · ValueError

The maximum number of generated images plus the number of re

Error message

The maximum number of generated images plus the number of reference images cannot exceed 15.

What it means

When sequential_image_generation is 'auto', Seedream requires total images (generated max_images + n_input_images references) to stay at or below 15. The node enforces this client-side because the API rejects the combination.

Source

Thrown at comfy_api_nodes/nodes_bytedance.py:727

        if "seedream-4-0" in model and out_num_pixels < 921600:
            raise ValueError(
                f"Minimum image resolution that the selected model can generate is 0.92MP, "
                f"but {mp_provided:.2f}MP provided."
            )
        max_pixels = 10_404_496 if "seedream-5-0" in model else 16_777_216
        if out_num_pixels > max_pixels:
            raise ValueError(
                f"Maximum image resolution for the selected model is {max_pixels / 1_000_000:.2f}MP, "
                f"but {mp_provided:.2f}MP provided."
            )
        n_input_images = get_number_of_images(image) if image is not None else 0
        max_num_of_images = 14 if model == "seedream-5-0-260128" else 10
        if n_input_images > max_num_of_images:
            raise ValueError(
                f"Maximum of {max_num_of_images} reference images are supported, but {n_input_images} received."
            )
        if sequential_image_generation == "auto" and n_input_images + max_images > 15:
            raise ValueError(
                "The maximum number of generated images plus the number of reference images cannot exceed 15."
            )
        reference_images_urls = []
        if n_input_images:
            for i in image:
                validate_image_aspect_ratio(i, (1, 3), (3, 1))
            reference_images_urls = await upload_images_to_comfyapi(
                cls,
                image,
                max_images=n_input_images,
                mime_type="image/png",
            )
        response = await sync_op(
            cls,
            ApiEndpoint(path=BYTEPLUS_IMAGE_ENDPOINT, method="POST"),
            response_model=ImageTaskCreationResponse,
            data=Seedream4TaskCreationRequest(
                model=model,

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Lower the max_images (number of generated images) widget so references + generated <= 15.
  2. Reduce the number of reference images.
  3. If you genuinely need more, run multiple generations - the cap is per request.

Example fix

// before
max_images: 6, image batch: 12 references, sequential_image_generation: 'auto'
// after
max_images: 3, image batch: 12 references, sequential_image_generation: 'auto'
Defensive patterns

Strategy: validation

Validate before calling

n_refs = len(reference_images) if reference_images is not None else 0
if sequential_image_generation == 'auto':
    max_images = min(max_images, 15 - n_refs)

Prevention

When it happens

Trigger: sequential_image_generation == 'auto' and n_input_images + max_images > 15 - e.g. 12 reference images plus 4 generated images.

Common situations: High max_images widget value combined with a large reference batch; sequential mode left on 'auto' while scaling up generation count.

Related errors


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