# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"15": {
"class_type": "ByteDance2ReferenceNode",
"inputs": {
"model": "Seedance 2.5",
"model.auto_downscale": True,
"model.auto_upscale": False,
"model.duration": 5,
"model.generate_audio": True,
"model.output_format": "mp4",
"model.prompt": "Transform the input video to clay style. Keep the motion, characters, composition, and timing exactly the same, only change the visual rendering. No additional content.",
"model.ratio": "adaptive",
"model.reference_videos.video_1": [
"36",
0
],
"model.resolution": "720p",
"model.video_editing": True,
"seed": 386595195,
"watermark": False
},
"_meta": {
"title": "ByteDance Seedance 2.5 Reference to Video (Legacy)"
}
},
"16": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/Seedance2.5_video_edit",
"format": "auto",
"format.codec": "auto",
"video": [
"15",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"35": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"36": {
"class_type": "Video Slice",
"inputs": {
"duration": 5,
"start_time": 0,
"strict_duration": False,
"video": [
"35",
0
]
},
"_meta": {
"title": "Trim Video"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("35", "file", client.assets.from_url("https://example.com/replace-with-a-url/video"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)