# 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({
"5": {
"class_type": "LumaImageToVideoNode",
"inputs": {
"duration": "5s",
"first_image": [
"9",
0
],
"loop": False,
"luma_concepts": [
"24",
0
],
"model": "ray-2",
"prompt": "A peach-colored dahlia flower with a green center, in the middle of ona a black background, photographed from a very low angle, shot on a Hasselblad H6D-400c with a Zeiss Milvus 25mm f/8 lens, highly detailed and realistic, in the style of National Geographic photography.",
"resolution": "720p",
"seed": 0
},
"_meta": {
"title": "Luma Image to Video"
}
},
"8": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "ComfyUI_video_luma",
"format": "auto",
"format.codec": "auto",
"video": [
"5",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"9": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "first_image"
}
},
"24": {
"class_type": "LumaConceptsNode",
"inputs": {
"concept1": "zoom_in",
"concept2": "orbit_left",
"concept3": "None",
"concept4": "None"
},
"_meta": {
"title": "Luma Concepts"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("9", "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)