{"record":{"id":"7b020b4b45363b5a","repo":"calesthio/OpenMontage","slug":"text-to-video-does-not-accept-reference-media-use","errorCode":null,"errorMessage":"text_to_video does not accept reference media; use image_to_video or reference_to_video","messagePattern":"text_to_video does not accept reference media; use image_to_video or reference_to_video","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/video/seedance_ark.py","lineNumber":740,"sourceCode":"\n        max_duration = 30 if variant == \"2.5\" else 15\n        duration = self._normalize_duration(inputs.get(\"duration\", 5), max_duration)\n        prompt = str(inputs.get(\"prompt\") or \"\").strip()\n        content: list[dict[str, Any]] = []\n        if prompt:\n            content.append({\"type\": \"text\", \"text\": prompt})\n\n        if inputs.get(\"reference_video_path\"):\n            raise ValueError(\n                \"reference_video_path is not supported by Ark; upload the \"\n                \"video to a public/signed HTTPS URL or Ark asset first\"\n            )\n\n        if operation == \"text_to_video\":\n            if not prompt:\n                raise ValueError(\"prompt is required for text_to_video\")\n            if self._has_any_media(inputs):\n                raise ValueError(\n                    \"text_to_video does not accept reference media; use \"\n                    \"image_to_video or reference_to_video\"\n                )\n        elif operation == \"image_to_video\":\n            first_refs = self._single_image_refs(inputs)\n            if len(first_refs) != 1:\n                raise ValueError(\"image_to_video requires exactly one reference image\")\n            content.append(self._image_content(first_refs[0], role=\"first_frame\"))\n            end_refs = [\n                value\n                for value in (\n                    inputs.get(\"end_image_url\"),\n                    inputs.get(\"end_image_path\"),\n                )\n                if value\n            ]\n            if len(end_refs) > 1:\n                raise ValueError(\"provide only one of end_image_url/end_image_path\")","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/video/seedance_ark.py#L722-L758","documentation":"Raised while building the Ark Seedance request payload when operation is 'text_to_video' but the inputs dict contains any reference media (image or video refs). The Ark text-to-video content array accepts only a text prompt; media references must go through image_to_video or reference_to_video. It fires before any network call, so no API quota is consumed.","triggerScenarios":"Calling the tool with operation='text_to_video' plus any of reference_image_urls/paths, reference_image_url/path, reference_video_urls, or reference_video_url populated. _has_any_media() returning True for any media key triggers it.","commonSituations":"Copy-pasting a reference_to_video input dict and only changing the operation field; pipelines that pass a fixed template of inputs to every operation; UI forms that always submit reference fields even when empty strings are replaced by defaults.","solutions":["Switch operation to 'reference_to_video' if you want the model to condition on the media","Switch operation to 'image_to_video' if you have exactly one first-frame image","Strip all reference_* media keys from inputs before calling with text_to_video"],"exampleFix":"# before\ninputs = {\"operation\": \"text_to_video\", \"prompt\": p, \"reference_image_urls\": [u]}\n\n# after\ninputs = {\"operation\": \"reference_to_video\", \"prompt\": p, \"reference_image_urls\": [u]}","handlingStrategy":"validation","validationCode":"MEDIA_KEYS = (\"reference_image_urls\", \"reference_image_paths\", \"reference_image_url\",\n                 \"reference_image_path\", \"reference_video_urls\", \"reference_video_url\")\n\ndef has_media(inputs):\n    return any(inputs.get(k) for k in MEDIA_KEYS)\n\ndef validate_t2v(inputs):\n    if inputs.get(\"operation\") == \"text_to_video\" and has_media(inputs):\n        raise ValueError(\"drop reference media or use reference_to_video\")","typeGuard":null,"tryCatchPattern":"try:\n    payload = builder.build(inputs)\nexcept ValueError as e:\n    if \"does not accept reference media\" in str(e):\n        inputs = {k: v for k, v in inputs.items() if k not in MEDIA_KEYS}\n        payload = builder.build(inputs)\n    else:\n        raise","preventionTips":["Build inputs per operation instead of sharing one template dict","Assert media keys are absent before text_to_video calls"],"tags":["validation","seedance","ark","input-validation","video-generation"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}