# 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({
"14": {
"class_type": "Vidu3ImageToVideoNode",
"inputs": {
"image": [
"16",
0
],
"model": "viduq3-pro",
"model.audio": True,
"model.duration": 6,
"model.resolution": "720p",
"prompt": "Shot 1 (0-2s): Boy turns alarmed, shouts: \"Run! NOW!\" They break pose, start running right, exit frame. Snow kicks up.\nShot 2 (2-4s): Side tracking. Running through forest hand-in-hand, hair streaming, trees blur past. Look back fearfully.\nShot 3 (4-6s): Low angle. Leap over log, airborne slow-mo, land and run into mist. Dark shapes pursue behind.\nSound: shout, rapid footsteps, breathing, branches, pursuit sounds. Color: increased contrast, dark shadows behind.",
"seed": 861064363
},
"_meta": {
"title": "Vidu Q3 Image-to-Video Generation"
}
},
"15": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/vidu_q3_i2v",
"format": "auto",
"format.codec": "auto",
"video": [
"14",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"16": {
"class_type": "LoadImage",
"inputs": {
"image": "two_characters.png"
},
"_meta": {
"title": "Load Image"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)