Comfy-Org/ComfyUI · error · ValueError
The current maximum number of supported images is 8.
Error message
The current maximum number of supported images is 8.
What it means
The FLUX 2 (Kontext-style) node enforces BFL's limit of 8 reference images per generation. Because inputs arrive as Autogrow slots that may each hold a batched tensor, the node flattens and counts every frame via get_number_of_images before building input_image_N base64 fields.
Source
Thrown at comfy_api_nodes/nodes_bfl.py:970
)
@classmethod
async def execute(
cls,
prompt: str,
model: dict,
seed: int,
) -> IO.NodeOutput:
model_choice = model["model"]
endpoint = _FLUX2_MODEL_ENDPOINTS[model_choice]
width = model["width"]
height = model["height"]
images_dict = model.get("images") or {}
image_tensors: list[Input.Image] = [t for t in images_dict.values() if t is not None]
n_images = sum(get_number_of_images(t) for t in image_tensors)
if n_images > 8:
raise ValueError("The current maximum number of supported images is 8.")
flat_tensors: list[torch.Tensor] = []
for tensor in image_tensors:
if len(tensor.shape) == 4:
flat_tensors.extend(tensor[i] for i in range(tensor.shape[0]))
else:
flat_tensors.append(tensor)
reference_images: dict[str, str] = {}
for idx, tensor in enumerate(flat_tensors):
key_name = f"input_image_{idx + 1}" if idx else "input_image"
reference_images[key_name] = tensor_to_base64_string(tensor, total_pixels=2048 * 2048)
initial_response = await sync_op(
cls,
ApiEndpoint(path=endpoint, method="POST"),
response_model=BFLFluxProGenerateResponse,
data=Flux2ProGenerateRequest(View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Trim total images (across all slots) to 8 or fewer before the call.
- Flatten your tensors first and keep only the ones you actually need.
- Split into two node invocations if you have more than 8 references.
Example fix
# before flat = [t for batch in image_tensors for t in batch] # 12 images -> ValueError # after flat = [t for batch in image_tensors for t in batch][:8]
Defensive patterns
Strategy: validation
Validate before calling
image_tensors = [t for t in (model.get("images") or {}).values() if t is not None]
n = sum(get_number_of_images(t) for t in image_tensors)
assert n <= 8, f"FLUX 2 accepts max 8 images, got {n}" Type guard
def flux2_refs_ok(images_dict: dict) -> bool:
return sum(get_number_of_images(t) for t in (images_dict or {}).values() if t is not None) <= 8 Prevention
- The 8-image budget is shared across all Autogrow slots.
- Flatten and trim before the call.
- Split oversized reference sets into sequential requests.
When it happens
Trigger: Calling a FLUX 2 model node where the sum of image counts across all non-None entries in the images dict exceeds 8 — e.g. two slots of 4-frame batches.
Common situations: Multiple Autogrow image inputs each carrying batches; forgetting that per-slot batches sum toward one shared limit; mixing grids and singletons.
Related errors
- The current maximum number of supported images is 9.
- FLUX 3 supports at most {_FLUX3_MAX_IMAGES} {field_name}, go
- Image aspect ratio is too extreme ({width}x{height}); FLUX 3
- Give one time per keyframe image: got {len(parts)} time(s) f
- Keyframe times must increase; got {times}.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/5dd7992aa30515da.
Report an issue: GitHub.