# 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({
"1": {
"class_type": "LoadImage",
"inputs": {
"image": "product_shoe.jpeg"
},
"_meta": {
"title": "Load Product Image"
}
},
"5": {
"class_type": "MinimaxHailuoVideoNode",
"inputs": {
"duration": 6,
"first_frame_image": [
"10",
0
],
"prompt_optimizer": True,
"prompt_text": "Product video — 360° rotating hero showcase of a white leather sneaker, cinematic soft spotlight, minimal studio background, seamless loop.",
"resolution": "1080P",
"seed": 111
},
"_meta": {
"title": "360 Rotation Vid - MiniMax Hailuo Video"
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"10",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"10": {
"class_type": "ByteDanceSeedreamNode",
"inputs": {
"fail_on_partial": True,
"height": 2048,
"image": [
"1",
0
],
"max_images": 1,
"model": "seedream-4-5-251128",
"prompt": "Professional studio product photography of a pristine white Adidas Samba sneaker from image 1, positioned at a dynamic three-quarter angle. The lighting is dramatic and cool-toned, featuring a hard spotlight that creates a glowing halo effect on the ground while casting soft shadows. The background is a seamless, clean gradient transitioning from a light silver-gray top to a deep anthracite black floor. Minimal composition with generous negative space, shot with shallow depth of field (f/2.8) to emphasize product details while softly blurring the background. ",
"seed": 555,
"sequential_image_generation": "disabled",
"size_preset": "1664x2496 (2:3)",
"watermark": False,
"width": 2048
},
"_meta": {
"title": "ByteDance Seedream 4.5 & 5.0"
}
},
"16": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI-1",
"format": "auto",
"format.codec": "auto",
"video": [
"5",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"17": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI-2",
"format": "auto",
"format.codec": "auto",
"video": [
"18",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"18": {
"class_type": "MinimaxHailuoVideoNode",
"inputs": {
"duration": 6,
"first_frame_image": [
"10",
0
],
"prompt_optimizer": True,
"prompt_text": "Product video — camera slowly zooms toward the sneaker, revealing texture details, light reflecting on the leather surface, cinematic shallow depth of field\n",
"resolution": "1080P",
"seed": 222
},
"_meta": {
"title": "Detailed Texture Vid - MiniMax Hailuo Video"
}
},
"19": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI-2",
"format": "auto",
"format.codec": "auto",
"video": [
"20",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"20": {
"class_type": "MinimaxHailuoVideoNode",
"inputs": {
"duration": 6,
"first_frame_image": [
"10",
0
],
"prompt_optimizer": True,
"prompt_text": "Product video — camera pans across the sneaker from heel to toe, dramatic cinematic light sweeps across, dust motes floating in the air",
"resolution": "1080P",
"seed": 333
},
"_meta": {
"title": "Cinematic Pan Vid - MiniMax Hailuo Video"
}
},
"30": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"27:27",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"27:22": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"5",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"27:23": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"18",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"27:24": {
"class_type": "ImageBatch",
"inputs": {
"image1": [
"27:22",
0
],
"image2": [
"27:23",
0
]
},
"_meta": {
"title": "Batch Images (DEPRECATED)"
}
},
"27:25": {
"class_type": "ImageBatch",
"inputs": {
"image1": [
"27:24",
0
],
"image2": [
"27:26",
0
]
},
"_meta": {
"title": "Batch Images (DEPRECATED)"
}
},
"27:26": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"20",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"27:27": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"27:22",
2
],
"images": [
"27:25",
0
]
},
"_meta": {
"title": "Create Video"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)