# 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({
"16": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/Seedance2.5_blockout",
"format": "auto",
"format.codec": "auto",
"video": [
"24",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"24": {
"class_type": "ByteDance2ReferenceNodeV2",
"inputs": {
"model": "Seedance 2.5",
"model.auto_downscale": True,
"model.auto_upscale": False,
"model.duration": 21,
"model.generate_audio": True,
"model.output_format": "mp4",
"model.prompt": "## Subject\n\nReference definitions. Use these labels exactly in the prompt:\n\n- `image_1`: the woman through whose eyes we watch. Wardrobe, hands, accessories and Walkman reference only. Never show her face, head or body: the film is first person.\n- `image_2`: 1985 New York subway car. Seats, poles, ceiling lights, graffiti, dark windows.\n- `image_3`: subway passengers, 1980s wardrobe, interior wear and lighting. Use with `image_2`.\n- `image_4`: the elderly woman. Identity, hair, maroon cardigan, floral dress, handbag, and her hollow eyeless face.\n- `video_1`: 21-second 3D blockout. Final authority for camera path, shot order, blocking, blackouts, and duration.\n\nHalf-full New York subway car, late night, 1985. The whole film is seen through the eyes of the young woman in `image_1`. The elderly woman from `image_4` is the horror: hunched, smiling, no eyes.\n\n## Action\n\nFollow `video_1` beat for beat. Do not add, remove or retime shots.\n\n1. Opening: seated first-person view, the car rocking, fluorescent light overhead.\n2. The lights flicker and fail. Breathing gets nervous. A small red light stays on.\n3. The lights return and the car is empty. The camera looks left, right and forward: nobody anywhere. The elderly woman has not appeared yet.\n4. She holds the forward view, then a dry old laugh comes from the far end and the camera turns right. Only now is the elderly woman revealed, seated at the back.\n5. Each blackout moves her closer: mid-car, then across the aisle, then inches from the lens. She never walks between positions.\n6. Final close-up: her eyeless face fills the frame. A hand reaches for the viewer's throat.\n\n## Camera\n\nStrict first-person POV for the entire 21 seconds. Use `video_1` for camera path, height, head turns, pauses, blackout timing and the final close-up. `image_1` is never a camera reference: no third-person shots of the woman, no turnaround sheet in frame. The subway layout, framing and perspectives come from `image_2` and `image_3`.\n\n## Audio and dialogue\n\nKeep the young woman's breathing and gasp nonverbal and quiet. The elderly woman's laugh is nonverbal. She speaks one line in deep, resonant American English, word for word: \"I bet you have pretty eyes... I'll take good care of them.\" Natural lip sync, no extra dialogue. The subway keeps its low rumble.\n",
"model.ratio": "16:9",
"model.reference_images.image_1": [
"26",
0
],
"model.reference_images.image_2": [
"32",
0
],
"model.reference_images.image_3": [
"37",
0
],
"model.reference_images.image_4": [
"36",
0
],
"model.reference_videos.video_1": [
"25",
0
],
"model.resolution": "720p",
"model.task_type": "reference",
"seed": 459506062,
"watermark": False
},
"_meta": {
"title": "ByteDance Seedance 2.5 Reference to Video"
}
},
"25": {
"class_type": "LoadVideo",
"inputs": {
"file": "subway_blockout.mp4"
},
"_meta": {
"title": "Load Video (subway_blockout.mp4)"
}
},
"26": {
"class_type": "LoadImage",
"inputs": {
"image": "subway_pov_woman.png"
},
"_meta": {
"title": "Load Image (subway_pov_woman.png)"
}
},
"32": {
"class_type": "LoadImage",
"inputs": {
"image": "subway_interior.png"
},
"_meta": {
"title": "Load Image (subway_interior.png)"
}
},
"36": {
"class_type": "LoadImage",
"inputs": {
"image": "subway_eyeless_woman.png"
},
"_meta": {
"title": "Load Image (subway_eyeless_woman.png)"
}
},
"37": {
"class_type": "LoadImage",
"inputs": {
"image": "subway_passengers.png"
},
"_meta": {
"title": "Load Image (subway_passengers.png)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)