# 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({
"9": {
"class_type": "ByteDanceCreateImageAsset",
"inputs": {
"group_id": "",
"image": [
"20",
0
]
},
"_meta": {
"title": "ByteDance Create Image Asset"
}
},
"12": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"9",
1
]
},
"_meta": {
"title": "Preview as Text (group_id)"
}
},
"15": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/Seedance2.0",
"format": "auto",
"format.codec": "auto",
"video": [
"36",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"18": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"9",
0
]
},
"_meta": {
"title": "Preview as Text (asset_id)"
}
},
"20": {
"class_type": "LoadImage",
"inputs": {
"image": "flf2v_demo_first_frame.png"
},
"_meta": {
"title": "Load Image (Real Human)"
}
},
"36": {
"class_type": "ByteDance2FirstLastFrameNode",
"inputs": {
"first_frame_asset_id": [
"18",
0
],
"last_frame_asset_id": [
"41",
0
],
"model": "Seedance 2.0",
"model.duration": 7,
"model.generate_audio": True,
"model.prompt": "[Style] Futuristic magical water observatory, 8K ultra-clear, Photorealistic, High-fashion Editorial, circular fountain platform, suspended liquid membranes, aurora color gradients, dreamlike sci-fi elegance, Unreal Engine 5 fluid simulation and atmospheric glow.\n\nProtagonist note:\nA female fashion model, mid-20s, editorial silhouette: shoulder-length auburn hair in loose waves, tall lean build, calm confident posture.\n\n[Duration] 5 seconds.\n\n[Scene] A circular observatory suspended above a dark luminous void; a ring-shaped fountain surrounds the platform; thin vertical water membranes hover like transparent walls, and the ceiling glows with aurora colors.\n\n[00:00-00:02] Shot 1: Fountain ring.\nCamera: medium-wide orbit around the circular platform; water ring and figure share the frame.\nAction: She walks along the fountain rim; the thin water membranes around the platform shimmer with the ceiling colors.\nEffect: The nearest water membranes begin to peel away from the fountain ring into soft liquid sheets that resemble miniature aurora walls.\n\n[00:02-00:04] Shot 2: Membrane rise.\nCamera: medium three-quarter on torso, the fountain rim, and nearby water curtain.\nAction: She raises both hands slowly.\nEffect: The liquid membranes peel fully away from the fountain ring and rise into tall aurora-tinted sheets, matching the observatory geometry.\n\n[00:04-00:05] Shot 3: Observatory dissolve.\nCamera: crane up into a top view of the circular space.\nAction: She remains in the center while the sheets expand beyond her.\nEffect: The fountain ring, floor circle, and hovering water walls all soften into luminous aurora washes, and the observatory disappears into a vast magical liquid sky.",
"model.ratio": "16:9",
"model.resolution": "480p",
"seed": 0,
"watermark": False
},
"_meta": {
"title": "ByteDance Seedance 2.5 First-Last-Frame to Video"
}
},
"37": {
"class_type": "ByteDanceCreateImageAsset",
"inputs": {
"group_id": "",
"image": [
"38",
0
]
},
"_meta": {
"title": "ByteDance Create Image Asset"
}
},
"38": {
"class_type": "LoadImage",
"inputs": {
"image": "flf2v_demo_last_frame.png"
},
"_meta": {
"title": "Load Image (Real Human)"
}
},
"39": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"37",
1
]
},
"_meta": {
"title": "Preview as Text (group_id)"
}
},
"41": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"37",
0
]
},
"_meta": {
"title": "Preview as Text (asset_id)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)