# 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({
"20": {
"class_type": "ViduImageToVideoNode",
"inputs": {
"duration": 5,
"image": [
"22",
0
],
"model": "viduq1",
"movement_amplitude": "auto",
"prompt": "A sleek leopard explodes into a full-speed sprint along a narrow jungle trail, dappled sunlight and warm sunbeams piercing a lush green canopy, pink blossoms and broad leaves whipping past. Low, front-tracking chase shot with subtle handheld shake; shallow depth of field, crisp focus on the leopard’s eyes, then a quick rack focus to paws striking dirt, kicking dust and leaf litter. Muscles ripple under the spotted coat; tail whips for balance; ears pinned; breath puffing in the cool air. Foreground plants streak with fast parallax and natural motion blur; petals and pollen tumble in the slipstream; tiny pebbles flick outward. Speed ramps from quick start to blistering pace. The leopard veers slightly, leaps over a gnarled root, passes within inches of the lens with a whoosh, then streaks past, leaving swirling dust, swaying foliage, and sunlit motes hanging in the air. Ultra-detailed, cinematic, 120fps feel, soft lens flare, vibrant colors, high contrast, realistic shadows.\n",
"resolution": "1080p",
"seed": 830994375
},
"_meta": {
"title": "Vidu Image To Video Generation"
}
},
"21": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"20",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"22": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("22", "image", client.assets.from_url("https://example.com/replace-with-a-url/image"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)