# 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({
"8": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"13",
1
]
},
"_meta": {
"title": "Preview as Text (generation_id)"
}
},
"11": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"12": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/Luma_Ray_3.2_I2V",
"format": "auto",
"format.codec": "auto",
"video": [
"13",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"13": {
"class_type": "LumaRay32ImageToVideoNode",
"inputs": {
"loop": False,
"prompt": "Monochrome black and white mechanical robotic sphynx cat, seamless segmented metal skull, countless thick data cables flowing from neck like dreadlocks, glowing narrow vertical white slit eyes, sleek cybernetic feline body built like a cheetah for sprinting, full-body running sprint pose, low tracking parallel camera moves alongside the robot cat to capture dynamic fast running motion, camera slowly pull back wide to reveal the entire streamlined cyber cat body, futuristic cyberpunk city environment, towering neon-lit metallic skyscrapers, glowing circuit billboards, wet reflective asphalt ground with hologram reflections, dense tech wiring infrastructure, industrial sci-fi atmosphere, dramatic cinematic side lighting, high contrast monochrome, hyper detailed mechanical textures, scratch worn metal panels, intricate bolt and gear details, motion blur on paws and cable tails to emphasize speed, 8K ultra realistic, photorealistic, shallow dynamic motion blur, epic sci-fi cinematography, sharp industrial blueprint background subtle overlay texture, no text, no watermark",
"resolution": "720p",
"seed": 569886435760230,
"start_frame": [
"11",
0
]
},
"_meta": {
"title": "Luma Ray 3.2 Image to Video"
}
}
})
workflow.set_input("11", "image", client.assets.from_url("https://comfy.org/catalog-media/e8174375-b406-46ec-a1a2-39768984f19c/750867ab-be35-4ad0-a9ea-d50a7cb4d0fd"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("12"):
output.to_file(output.name)