Comfy-Org/ComfyUI · error · ValueError

Aleph2 supports at most 5 keyframes.

Error message

Aleph2 supports at most 5 keyframes.

What it means

Raised by the Aleph2 node when the keyframes collection contains more than 5 items. The Runway Aleph2 API caps keyframe guidance at 5 images per request, and the node enforces this before uploading any of the keyframe images.

Source

Thrown at comfy_api_nodes/nodes_runway.py:796

        if (keyframes and keyframes.items) and (prompt_images and prompt_images.items):
            raise ValueError("Aleph2 accepts either keyframes or prompt images, not both.")

        video_duration: float | None = None
        try:
            video_duration = video.get_duration()
        except Exception:
            video_duration = None

        def _check_seconds(value: float, label: str) -> None:
            if video_duration is not None and value > video_duration + 0.0001:
                raise ValueError(f"{label} {value:.2f}s exceeds the input video duration ({video_duration:.2f}s).")

        video_url = await upload_video_to_comfyapi(cls, video)

        keyframe_models: list[RunwayAleph2KeyframeSeconds | RunwayAleph2KeyframeAt] = []
        if keyframes is not None:
            if len(keyframes.items) > 5:
                raise ValueError("Aleph2 supports at most 5 keyframes.")
            for item in keyframes.items:
                image_url = await upload_image_to_comfyapi(cls, item.image, mime_type="image/png")
                if item.mode == KEYFRAME_MODE_SECONDS:
                    _check_seconds(item.value, "Keyframe timestamp")
                    keyframe_models.append(RunwayAleph2KeyframeSeconds(seconds=item.value, uri=image_url))
                else:
                    keyframe_models.append(RunwayAleph2KeyframeAt(at=item.value, uri=image_url))

        prompt_image_models: list[RunwayAleph2PromptImage] = []
        if prompt_images is not None:
            if len(prompt_images.items) > 5:
                raise ValueError("Aleph2 supports at most 5 prompt images.")
            for item in prompt_images.items:
                image_url = await upload_image_to_comfyapi(cls, item.image, mime_type="image/png")
                position: RunwayAleph2TimestampPosition | RunwayAleph2RelativePosition
                if item.mode == PROMPT_IMAGE_MODE_TIMESTAMP:
                    _check_seconds(item.value, "Prompt image timestamp")
                    position = RunwayAleph2TimestampPosition(timestampSeconds=item.value)

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Trim the keyframe list to at most 5 items, keeping the most temporally significant frames
  2. If more coverage is needed, split into two Aleph2 runs over sub-clips

Example fix

// before
aleph2(prompt, video, keyframes=all_9_keyframes)

// after
aleph2(prompt, video, keyframes=all_9_keyframes[:5])
Defensive patterns

Strategy: validation

Validate before calling

assert keyframes is None or len(keyframes.items) <= 5, "Aleph2: at most 5 keyframes"

Type guard

def keyframe_count_ok(keyframes) -> bool:
    return keyframes is None or len(keyframes.items) <= 5

Try / catch

try:
    await aleph2_execute(...)
except ValueError as e:
    if "at most 5 keyframes" in str(e):
        keyframes.items = keyframes.items[:5]
        await aleph2_execute(...)
    else:
        raise

Prevention

When it happens

Trigger: Connecting a keyframes aggregation with 6+ items (each item = one image + timestamp) to the Aleph2 node's keyframes input.

Common situations: Dense keyframing workflows that mark every scene change; aggregating multiple RunwayAleph2KeyframeNode outputs into one list.

Related errors


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