# 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({
"10": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "hunyuan_video_vae_bf16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"11": {
"class_type": "DualCLIPLoader",
"inputs": {
"clip_name1": "clip_l.safetensors",
"clip_name2": "llava_llama3_fp8_scaled.safetensors",
"device": "default",
"type": "hunyuan_video"
},
"_meta": {
"title": "Load CLIP (Dual)"
}
},
"12": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "hunyuan_video_t2v_720p_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"13": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"22",
0
],
"latent_image": [
"45",
0
],
"noise": [
"25",
0
],
"sampler": [
"16",
0
],
"sigmas": [
"17",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"16": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"17": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"12",
0
],
"scheduler": "simple",
"steps": 20
},
"_meta": {
"title": "BasicScheduler"
}
},
"22": {
"class_type": "BasicGuider",
"inputs": {
"conditioning": [
"26",
0
],
"model": [
"67",
0
]
},
"_meta": {
"title": "Basic Guider"
}
},
"25": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 1
},
"_meta": {
"title": "RandomNoise"
}
},
"26": {
"class_type": "FluxGuidance",
"inputs": {
"conditioning": [
"44",
0
],
"guidance": 6
},
"_meta": {
"title": "FluxGuidance"
}
},
"44": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"11",
0
],
"text": "anime style anime girl with massive fennec ears and one big fluffy tail, she has blonde hair long hair blue eyes wearing a pink sweater and a long blue skirt walking in a beautiful outdoor scenery with snow mountains in the background"
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"45": {
"class_type": "EmptyHunyuanLatentVideo",
"inputs": {
"batch_size": 1,
"height": 480,
"length": 73,
"width": 848
},
"_meta": {
"title": "Empty Hunyuan Video 1.0 Latent"
}
},
"67": {
"class_type": "ModelSamplingSD3",
"inputs": {
"model": [
"12",
0
],
"shift": 7
},
"_meta": {
"title": "ModelSamplingSD3"
}
},
"73": {
"class_type": "VAEDecodeTiled",
"inputs": {
"overlap": 64,
"samples": [
"13",
0
],
"temporal_overlap": 8,
"temporal_size": 64,
"tile_size": 256,
"vae": [
"10",
0
]
},
"_meta": {
"title": "VAE Decode (Tiled)"
}
},
"79": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": 24,
"images": [
"73",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"80": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"79",
0
]
},
"_meta": {
"title": "Save Video"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)