calesthio/OpenMontage · error · ValueError

image_to_video requires image_url or image_path

Error message

image_to_video requires image_url or image_path

What it means

Raised during payload construction when operation=image_to_video is selected but neither image_url nor image_path was provided. _normalize_media_ref returns None for both missing inputs, and the tool refuses to build an image-to-video request without a source image — this fails fast before any API call.

Source

Thrown at tools/video/grok_video.py:199

    def _build_payload(self, inputs: dict[str, Any]) -> dict[str, Any]:
        operation = inputs.get("operation", "text_to_video")
        payload: dict[str, Any] = {
            "model": inputs.get("model", "grok-imagine-video"),
            "prompt": inputs["prompt"],
        }

        if operation != "reference_to_video":
            payload["duration"] = int(inputs.get("duration", 5))
            if inputs.get("aspect_ratio"):
                payload["aspect_ratio"] = inputs["aspect_ratio"]
            if inputs.get("resolution"):
                payload["resolution"] = self._normalize_resolution(inputs["resolution"])

        if operation == "image_to_video":
            image = _normalize_media_ref(inputs.get("image_url"), inputs.get("image_path"))
            if not image:
                raise ValueError("image_to_video requires image_url or image_path")
            payload["image"] = image
        elif operation == "reference_to_video":
            refs = [{"url": url} for url in (inputs.get("reference_image_urls") or [])]
            refs.extend(
                {"url": _file_to_data_uri(path)}
                for path in (inputs.get("reference_image_paths") or [])
            )
            if not refs:
                raise ValueError(
                    "reference_to_video requires reference_image_urls or reference_image_paths"
                )
            payload["reference_images"] = refs
            payload["duration"] = int(inputs.get("duration", 5))
            if inputs.get("aspect_ratio"):
                payload["aspect_ratio"] = inputs["aspect_ratio"]
            if inputs.get("resolution"):
                payload["resolution"] = self._normalize_resolution(inputs["resolution"])

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Add image_url (remote) or image_path (local file) to the inputs for image_to_video.
  2. Switch operation to text_to_video if no source image is intended.
  3. Check for key typos — the exact keys are image_url and image_path.

Example fix

# before
{"operation": "image_to_video", "prompt": "..."}  # no image

# after
{"operation": "image_to_video", "prompt": "...", "image_path": "/abs/first_frame.png"}
Defensive patterns

Strategy: validation

Validate before calling

def validate_grok_inputs(inputs: dict) -> None:
    op = inputs.get("operation", "text_to_video")
    if op == "image_to_video" and not (inputs.get("image_url") or inputs.get("image_path")):
        raise ValueError("image_to_video needs image_url or image_path")
    if op == "reference_to_video" and not (
        inputs.get("reference_image_urls") or inputs.get("reference_image_paths")
    ):
        raise ValueError("reference_to_video needs reference lists")

Prevention

When it happens

Trigger: Calling grok_video with operation='image_to_video' and inputs lacking both the image_url and image_path keys (or both empty/None).

Common situations: Copy-pasting a text_to_video input dict and only changing the operation string; upstream code conditionally setting the image key and the condition silently skipping it; key-name typos like image_urls or imagePath.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/ac48e66acdb99c67. Report an issue: GitHub.