# 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({
"104": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/LTX-2",
"format": "auto",
"format.codec": "auto",
"video": [
"177:114",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"177:100": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "ltx-2-19b-distilled.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"177:101": {
"class_type": "LTXVAudioVAELoader",
"inputs": {
"ckpt_name": "ltx-2-19b-distilled.safetensors"
},
"_meta": {
"title": "Load LTXV Audio VAE"
}
},
"177:102": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"177:111",
0
],
"text": [
"177:109",
0
]
},
"_meta": {
"title": "enhanced prompt (positive)"
}
},
"177:103": {
"class_type": "LTXVConditioning",
"inputs": {
"frame_rate": [
"177:112",
0
],
"negative": [
"177:102",
0
],
"positive": [
"177:102",
0
]
},
"_meta": {
"title": "LTXVConditioning"
}
},
"177:106": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 24
},
"_meta": {
"title": "Frame Rate (Int)"
}
},
"177:109": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "A man in a black tuxedo stands motionless in a small, red-tiled bathroom, facing a mirror. The camera sits just behind his right shoulder, framing both his back and his solemn reflection. Suddenly, he opens his mouth and begins to sing opera in Italian: \"La donna è mobile, qual piuma al vento.\" Rich, resonant notes echo through the space. As his voice climbs in pitch, his brows lift, and his expression becomes more passionate, almost vulnerable. The overhead lighting casts a sharp glow on his face and tuxedo, reflecting in the glossy red tiles around him. The camera is static"
},
"_meta": {
"title": "Positive prompt"
}
},
"177:110": {
"class_type": "LatentUpscaleModelLoader",
"inputs": {
"model_name": "ltx-2-spatial-upscaler-x2-1.0.safetensors"
},
"_meta": {
"title": "Load Latent Upscale Model"
}
},
"177:111": {
"class_type": "LTXAVTextEncoderLoader",
"inputs": {
"ckpt_name": "ltx-2-19b-distilled.safetensors",
"device": "default",
"text_encoder": "gemma_3_12B_it_fp4_mixed.safetensors"
},
"_meta": {
"title": "Load LTXV Audio Text Encoder"
}
},
"177:112": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 24
},
"_meta": {
"title": "Frame Rate (Float)"
}
},
"177:113": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 121
},
"_meta": {
"title": "Frame Count"
}
},
"177:114": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"177:120",
0
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"177:112",
0
],
"images": [
"177:119",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"177:115": {
"class_type": "LTXVEmptyLatentAudio",
"inputs": {
"audio_vae": [
"177:101",
0
],
"batch_size": 1,
"frame_rate": [
"177:106",
0
],
"frames_number": [
"177:113",
0
]
},
"_meta": {
"title": "Empty LTXV Latent Audio"
}
},
"177:116": {
"class_type": "EmptyLTXVLatentVideo",
"inputs": {
"batch_size": 1,
"height": [
"177:122",
1
],
"length": [
"177:113",
0
],
"width": [
"177:122",
0
]
},
"_meta": {
"title": "Empty LTXV Latent Video"
}
},
"177:117": {
"class_type": "ManualSigmas",
"inputs": {
"sigmas": "0.909375, 0.725, 0.421875, 0.0"
},
"_meta": {
"title": "ManualSigmas"
}
},
"177:118": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 420
},
"_meta": {
"title": "RandomNoise"
}
},
"177:119": {
"class_type": "VAEDecodeTiled",
"inputs": {
"overlap": 64,
"samples": [
"177:130",
0
],
"temporal_overlap": 8,
"temporal_size": 4096,
"tile_size": 512,
"vae": [
"177:100",
2
]
},
"_meta": {
"title": "VAE Decode (Tiled)"
}
},
"177:120": {
"class_type": "LTXVAudioVAEDecode",
"inputs": {
"audio_vae": [
"177:101",
0
],
"samples": [
"177:130",
1
]
},
"_meta": {
"title": "LTXV Audio VAE Decode"
}
},
"177:121": {
"class_type": "ImageScaleBy",
"inputs": {
"image": [
"177:131",
0
],
"scale_by": 0.5,
"upscale_method": "nearest-exact"
},
"_meta": {
"title": "Upscale Image By"
}
},
"177:122": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"177:121",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"177:123": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 45
},
"_meta": {
"title": "RandomNoise"
}
},
"177:124": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 1,
"model": [
"177:100",
0
],
"negative": [
"177:103",
1
],
"positive": [
"177:103",
0
]
},
"_meta": {
"title": "CFG Guider"
}
},
"177:125": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"177:127",
0
],
"latent_image": [
"177:132",
0
],
"noise": [
"177:123",
0
],
"sampler": [
"177:126",
0
],
"sigmas": [
"177:176",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"177:126": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler_ancestral"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"177:127": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 1,
"model": [
"177:100",
0
],
"negative": [
"177:103",
1
],
"positive": [
"177:103",
0
]
},
"_meta": {
"title": "CFG Guider"
}
},
"177:128": {
"class_type": "LTXVConcatAVLatent",
"inputs": {
"audio_latent": [
"177:133",
1
],
"video_latent": [
"177:135",
0
]
},
"_meta": {
"title": "Concat AV Latent"
}
},
"177:129": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler_ancestral"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"177:130": {
"class_type": "LTXVSeparateAVLatent",
"inputs": {
"av_latent": [
"177:134",
1
]
},
"_meta": {
"title": "Separate AV Latent"
}
},
"177:131": {
"class_type": "EmptyImage",
"inputs": {
"batch_size": 1,
"color": 0,
"height": 720,
"width": 1280
},
"_meta": {
"title": "Empty Image"
}
},
"177:132": {
"class_type": "LTXVConcatAVLatent",
"inputs": {
"audio_latent": [
"177:115",
0
],
"video_latent": [
"177:116",
0
]
},
"_meta": {
"title": "Concat AV Latent"
}
},
"177:133": {
"class_type": "LTXVSeparateAVLatent",
"inputs": {
"av_latent": [
"177:125",
1
]
},
"_meta": {
"title": "Separate AV Latent"
}
},
"177:134": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"177:124",
0
],
"latent_image": [
"177:128",
0
],
"noise": [
"177:118",
0
],
"sampler": [
"177:129",
0
],
"sigmas": [
"177:117",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"177:135": {
"class_type": "LTXVLatentUpsampler",
"inputs": {
"samples": [
"177:133",
0
],
"upscale_model": [
"177:110",
0
],
"vae": [
"177:100",
2
]
},
"_meta": {
"title": "LTXVLatentUpsampler"
}
},
"177:176": {
"class_type": "ManualSigmas",
"inputs": {
"sigmas": "1., 0.99375, 0.9875, 0.98125, 0.975, 0.909375, 0.725, 0.421875, 0.0"
},
"_meta": {
"title": "ManualSigmas"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)