# 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({
"11": {
"class_type": "MinimaxHailuoVideoNode",
"inputs": {
"duration": 6,
"first_frame_image": [
"13",
0
],
"prompt_optimizer": True,
"prompt_text": "Dreamlike porcelain figurine of a serene girl, pastel-blue glassy hair crowned with translucent white, red, pink, and orange blossoms gently swaying in a warm breeze, petals sparkling and drifting, hair strands rippling with subtle light reflections dancing across glossy surfaces, soft bokeh background.",
"resolution": "768P",
"seed": 0
},
"_meta": {
"title": "MiniMax Hailuo 02 Video"
}
},
"13": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"14": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"11",
0
]
},
"_meta": {
"title": "Save Video"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("13", "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)