# 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({
"343": {
"class_type": "ByteDance2TextToVideoNode",
"inputs": {
"model": "Seedance 2.0",
"model.duration": 5,
"model.generate_audio": True,
"model.prompt": "A cinematic fantasy sequence captures a young woman leaping across a shattered glacial chasm high above a tempestuous northern sea. The palette is dominated by crystalline cyan, seafoam white, and deep ocean navy. Shot with an ultra-wide 24mm lens from a dramatic low angle, the camera performs a continuous, soaring crane move, rising rapidly alongside her as she sprints toward the edge of the ice shelf and hurls herself forward into the roaring wind, her frost-dusted woolen cloak trailing behind her like a banner. Sub-zero mist swirls violently through the frigid air as colossal waves shatter against jagged icebergs far below. Ambient sound features the deep, percussive roar of fracturing pack ice, the deafening scream of coastal gale winds, and the resonant crash of surging surf against frozen cliffs.",
"model.ratio": "16:9",
"model.resolution": "720p",
"seed": 675586000,
"watermark": False
},
"_meta": {
"title": "ByteDance Seedance 2.5 Text to Video"
}
},
"344": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/Seedance2.0_t2v",
"format": "auto",
"format.codec": "auto",
"video": [
"343",
0
]
},
"_meta": {
"title": "Save Video"
}
}
})
# 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)