# 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({
"344": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/Seedance2.0_r2v",
"format": "auto",
"format.codec": "auto",
"video": [
"347",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"347": {
"class_type": "ByteDance2ReferenceNode",
"inputs": {
"model": "Seedance 2.0",
"model.auto_downscale": False,
"model.auto_upscale": False,
"model.duration": 7,
"model.generate_audio": True,
"model.prompt": "fast-paced editorial fashion film; the model from image 1 floats weightless in a pale blue studio among a gold dragon head with a glowing red horn, a molten chrome mask, and looping cream and tiger-striped ribbons above surging blue water. Dynamic handheld camera throughout: fast whip-pans, a sweeping 180-degree orbit around her, low-angle push-ins, a rising crane move and a final crash zoom, with energetic motion blur and slight fisheye distortion. [0–2s] maroon damask jacket and tangerine silk shirt (image 1), the camera orbits around her as she spins; [2–3.5s] whip-pan glitch cut to the cream silk column dress with maroon obi belt (image 2), low-angle push-in as the silk ripples; [3.5–5s] whip-pan glitch cut to the cream quilted jacket and tangerine wide-leg trousers (image 3), the camera cranes up and over her; [5–7s] glitch cut to the tangerine cocoon coat over a gold lamé dress with maroon boots (image 4), crash zoom into her face as she winks. Vibrant color grading, cinematic motion blur, hyper-real, consistent character and outfit in each segment, no outfit mixing, sharp focus on clothing details.",
"model.ratio": "16:9",
"model.reference_images.image_1": [
"356",
0
],
"model.reference_images.image_2": [
"352",
0
],
"model.reference_images.image_3": [
"353",
0
],
"model.reference_images.image_4": [
"354",
0
],
"model.resolution": "720p",
"seed": 1077699876,
"watermark": False
},
"_meta": {
"title": "ByteDance Seedance 2.5 Reference to Video (Legacy)"
}
},
"352": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_2_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"353": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_3_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"354": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_4_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"356": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_1_FILENAME"
},
"_meta": {
"title": "Load Image"
}
}
})
workflow.set_input("356", "image", client.assets.from_url("https://comfy.org/catalog-media/b0125ee1-91d3-4e1f-be18-65431a51d91e/3879160b-7923-4390-a375-d17459c9f550"))
workflow.set_input("352", "image", client.assets.from_url("https://comfy.org/catalog-media/ad554297-29b3-4f79-b5db-e9c657eca068/cb544ea4-b486-424e-9210-ad1501d2c2b1"))
workflow.set_input("353", "image", client.assets.from_url("https://comfy.org/catalog-media/fbe69c07-76d0-45a6-ae45-96e39c471719/1dc6865e-ae44-4681-8124-092a5407d6a8"))
workflow.set_input("354", "image", client.assets.from_url("https://comfy.org/catalog-media/5949743f-ce13-4757-951d-cb009aa71a73/e04b2bc3-41dd-4712-be11-bc8230b9b03e"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("344"):
output.to_file(output.name)