# 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": "VAEDecode",
"inputs": {
"samples": [
"127",
0
],
"vae": [
"10",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"10": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "hunyuanvideo15_vae_fp16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"11": {
"class_type": "DualCLIPLoader",
"inputs": {
"clip_name1": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"clip_name2": "byt5_small_glyphxl_fp16.safetensors",
"device": "default",
"type": "hunyuan_video_15"
},
"_meta": {
"title": "Load CLIP (Dual)"
}
},
"12": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "hunyuanvideo1.5_720p_t2v_fp16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"44": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"11",
0
],
"text": "A paper airplane released from the top of a skyscraper, gliding through urban canyons, crossing traffic, flying over streets, spiraling upward between buildings. The camera follows the paper airplane's perspective, shooting cityscape in first-person POV, finally flying toward the sunset, disappearing in golden light. Creative camera movement, free perspective, dreamlike colors."
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"93": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"11",
0
],
"text": ""
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"101": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": 24,
"images": [
"8",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"102": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/hunyuan_video_1.5",
"format": "auto",
"format.codec": "h264",
"video": [
"101",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"124": {
"class_type": "EmptyHunyuanVideo15Latent",
"inputs": {
"batch_size": 1,
"height": 720,
"length": 121,
"width": 1280
},
"_meta": {
"title": "Empty Hunyuan Video 1.5 Latent"
}
},
"127": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"131",
0
],
"latent_image": [
"124",
0
],
"noise": [
"129",
0
],
"sampler": [
"130",
0
],
"sigmas": [
"128",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"128": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"12",
0
],
"scheduler": "simple",
"steps": 20
},
"_meta": {
"title": "BasicScheduler"
}
},
"129": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 887963123424675
},
"_meta": {
"title": "RandomNoise"
}
},
"130": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"131": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 6,
"model": [
"132",
0
],
"negative": [
"93",
0
],
"positive": [
"44",
0
]
},
"_meta": {
"title": "CFG Guider"
}
},
"132": {
"class_type": "ModelSamplingSD3",
"inputs": {
"model": [
"12",
0
],
"shift": 7
},
"_meta": {
"title": "ModelSamplingSD3"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)