calesthio/OpenMontage · error · ValueError

Kling image response contained no images

Error message

Kling image response contained no images

What it means

ValueError from _download_images when the Kling API response parses successfully but contains zero image outputs to download. The tool treats an empty outputs list as a contract failure: the generation call 'succeeded' yet produced nothing retrievable.

Source

Thrown at tools/graphics/kling_official_image.py:371

            if not value:
                raise ValueError("image_list items must include image, image_url, or image_path")
            add_image(value, source=source, source_type="image_list")
        for url in inputs.get("image_urls") or []:
            add_image(normalize_image_input(url=url), source=url, source_type="image_urls")
        for path in inputs.get("image_paths") or []:
            add_image(normalize_image_input(path=path), source=str(path), source_type="image_paths")
        if inputs.get("image_url") or inputs.get("image_path"):
            add_image(
                normalize_image_input(inputs.get("image_url"), inputs.get("image_path")),
                source=inputs.get("image_url") or inputs.get("image_path"),
                source_type="image",
            )

        return image_list, references_used

    def _download_images(self, client: KlingClient, outputs: list[dict[str, Any]], inputs: dict[str, Any]) -> list[Path]:
        if not outputs:
            raise ValueError("Kling image response contained no images")
        base_path = Path(inputs.get("output_path", "kling_official_image.png"))
        paths: list[Path] = []
        for index, item in enumerate(outputs):
            url = self._output_url(item)
            suffix = extension_from_url(url, ".png")
            output_path = numbered_output_path(output_path_with_suffix(base_path, suffix), index, suffix)
            client.download(url, output_path)
            paths.append(output_path)
        return paths

    @staticmethod
    def _output_url(item: dict[str, Any]) -> str:
        url = item.get("url") or item.get("image_url") or item.get("resource_url")
        if url:
            return str(url)
        resource = item.get("resource") or {}
        if isinstance(resource, dict) and resource.get("url"):
            return str(resource["url"])

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Inspect the raw Kling response payload (log it at the call site) to see whether images exist under a different key
  2. Rephrase the prompt to avoid likely-filtered content and retry
  3. Verify the model/endpoint combination actually returns synchronous images (some flows return task ids instead)
  4. If the key moved upstream, update _output_url/outputs extraction in kling_official_image.py
Defensive patterns

Strategy: try-catch

Try / catch

try:
    paths = tool._download_images(client, outputs, inputs)
except ValueError as e:
    if "no images" in str(e):
        # inspect raw response; empty output is often content filtering or schema drift
        raise

Prevention

When it happens

Trigger: Kling API returns a success-shaped response with an empty data/images array; content filtering that suppresses outputs without an error status; response schema drift moving images to a different key so the extractor finds none.

Common situations: Policy-filtered prompts that return quietly empty results; API updates renaming the images field; partially-successful batch requests where all items were dropped.

Related errors


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