# 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({
"75": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/LTX-2.5_i2v",
"format": "auto",
"format.codec": "auto",
"video": [
"398:370",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"395": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load First Frame"
}
},
"403": {
"class_type": "ResolutionSelector",
"inputs": {
"aspect_ratio": "16:9 (Widescreen)",
"megapixels": 0.9,
"multiple": 32
},
"_meta": {
"title": "Resolution Selector"
}
},
"398:338": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 42
},
"_meta": {
"title": "RandomNoise"
}
},
"398:339": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 72790129095462
},
"_meta": {
"title": "RandomNoise"
}
},
"398:340": {
"class_type": "LTXVConcatAVLatent",
"inputs": {
"audio_latent": [
"398:367",
1
],
"video_latent": [
"398:349",
0
]
},
"_meta": {
"title": "Concat AV Latent"
}
},
"398:341": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler_ancestral"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"398:344": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"398:388",
0
],
"latent_image": [
"398:377",
0
],
"noise": [
"398:339",
0
],
"sampler": [
"398:352",
0
],
"sigmas": [
"398:397",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"398:348": {
"class_type": "LTXVLatentUpsampler",
"inputs": {
"samples": [
"398:367",
0
],
"upscale_model": [
"398:371",
0
],
"vae": [
"398:385",
0
]
},
"_meta": {
"title": "LTXVLatentUpsampler"
}
},
"398:349": {
"class_type": "LTXVImgToVideoInplace",
"inputs": {
"bypass": [
"398:363",
0
],
"image": [
"398:350",
0
],
"latent": [
"398:348",
0
],
"strength": 1,
"vae": [
"398:385",
0
]
},
"_meta": {
"title": "LTXVImgToVideoInplace"
}
},
"398:350": {
"class_type": "LTXVPreprocess",
"inputs": {
"image": [
"398:351",
0
],
"img_compression": 18
},
"_meta": {
"title": "LTXV Preprocess"
}
},
"398:351": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"395",
0
],
"resize_type": "scale longer dimension",
"resize_type.longer_size": 1536,
"scale_method": "lanczos"
},
"_meta": {
"title": "Resize Image/Mask"
}
},
"398:352": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler_ancestral"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"398:353": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a/2",
"values.a": [
"398:372",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"398:355": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a/2",
"values.a": [
"398:360",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"398:356": {
"class_type": "EmptyLTXVLatentVideo",
"inputs": {
"batch_size": 1,
"height": [
"398:355",
1
],
"length": [
"398:378",
1
],
"width": [
"398:353",
1
]
},
"_meta": {
"title": "Empty LTXV Latent Video"
}
},
"398:357": {
"class_type": "LTXVImgToVideoInplace",
"inputs": {
"bypass": [
"398:363",
0
],
"image": [
"398:350",
0
],
"latent": [
"398:356",
0
],
"strength": 0.7,
"vae": [
"398:385",
0
]
},
"_meta": {
"title": "LTXVImgToVideoInplace"
}
},
"398:358": {
"class_type": "LTXVAudioVAEDecode",
"inputs": {
"audio_vae": [
"398:386",
0
],
"samples": [
"398:369",
1
]
},
"_meta": {
"title": "LTXV Audio VAE Decode"
}
},
"398:359": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"398:361",
0
]
},
"_meta": {
"title": "Math Expression (fps)"
}
},
"398:360": {
"class_type": "PrimitiveInt",
"inputs": {
"value": [
"403",
1
]
},
"_meta": {
"title": "Height"
}
},
"398:361": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 24
},
"_meta": {
"title": "Frame Rate"
}
},
"398:362": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 5
},
"_meta": {
"title": "Duration"
}
},
"398:363": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": False
},
"_meta": {
"title": "Switch to Text to Video?"
}
},
"398:364": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"398:387",
0
],
"text": [
"398:382",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"398:365": {
"class_type": "LTXVConditioning",
"inputs": {
"frame_rate": [
"398:359",
0
],
"negative": [
"398:373",
0
],
"positive": [
"398:364",
0
]
},
"_meta": {
"title": "LTXVConditioning"
}
},
"398:366": {
"class_type": "LTXVEmptyLatentAudio",
"inputs": {
"audio_vae": [
"398:386",
0
],
"batch_size": 1,
"frame_rate": [
"398:359",
1
],
"frames_number": [
"398:378",
1
]
},
"_meta": {
"title": "Empty LTXV Latent Audio"
}
},
"398:367": {
"class_type": "LTXVSeparateAVLatent",
"inputs": {
"av_latent": [
"398:344",
0
]
},
"_meta": {
"title": "Separate AV Latent"
}
},
"398:368": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"398:391",
0
],
"latent_image": [
"398:340",
0
],
"noise": [
"398:338",
0
],
"sampler": [
"398:341",
0
],
"sigmas": [
"398:396",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"398:369": {
"class_type": "LTXVSeparateAVLatent",
"inputs": {
"av_latent": [
"398:368",
0
]
},
"_meta": {
"title": "Separate AV Latent"
}
},
"398:370": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"398:358",
0
],
"bit_depth": 8,
"codec": "none",
"color_space": "sRGB",
"fps": [
"398:359",
0
],
"images": [
"398:374",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"398:371": {
"class_type": "LatentUpscaleModelLoader",
"inputs": {
"model_name": "ltx-2.5-latent-spatial-upscaler-x2-bf16-1.0.safetensors"
},
"_meta": {
"title": "Load Latent Upscale Model"
}
},
"398:372": {
"class_type": "PrimitiveInt",
"inputs": {
"value": [
"403",
0
]
},
"_meta": {
"title": "Width"
}
},
"398:373": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"398:387",
0
],
"text": "pc game, console game, video game, cartoon, childish, ugly"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"398:374": {
"class_type": "VAEDecodeTiled",
"inputs": {
"overlap": 64,
"samples": [
"398:369",
0
],
"temporal_overlap": 32,
"temporal_size": 4096,
"tile_size": 768,
"vae": [
"398:385",
0
]
},
"_meta": {
"title": "VAE Decode (Tiled)"
}
},
"398:376": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "Use the provided start image as the first frame. The large moth resting on the bridge of the person's nose slowly opens and closes its patterned wings, the eyespots catching the golden light, its fuzzy antennae twitching. The person breathes calmly, then blinks once and turns their head a few degrees toward the camera, a faint glow pulsing in the amber lens flare that streaks from the corner of the eye across the darkness. Tiny golden dust motes drift through the beam. The camera starts in a medium close-up and makes a slow, smooth push-in toward the face, settling on the moth's wings and the person's steady gaze. Hard side light rakes across the gold-tinted skin, showing fine texture. Soft ambient hum, the faint flutter of wings. Surreal, cinematic, intimate."
},
"_meta": {
"title": "Prompt"
}
},
"398:377": {
"class_type": "LTXVConcatAVLatent",
"inputs": {
"audio_latent": [
"398:366",
0
],
"video_latent": [
"398:357",
0
]
},
"_meta": {
"title": "Concat AV Latent"
}
},
"398:378": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a * b + 1",
"values.a": [
"398:362",
0
],
"values.b": [
"398:361",
0
]
},
"_meta": {
"title": "Math Expression (length)"
}
},
"398:380": {
"class_type": "TextGenerateLTX2Prompt",
"inputs": {
"clip": [
"398:393",
0
],
"image": [
"398:350",
0
],
"max_length": 600,
"mtp": "auto",
"prompt": [
"398:376",
0
],
"sampling_mode": "on",
"sampling_mode.min_p": 0.05,
"sampling_mode.presence_penalty": 0,
"sampling_mode.repetition_penalty": 1.15,
"sampling_mode.seed": 0,
"sampling_mode.temperature": 0.7,
"sampling_mode.top_k": 64,
"sampling_mode.top_p": 0.95,
"thinking": False,
"use_default_template": True
},
"_meta": {
"title": "Generate LTX2 Prompt"
}
},
"398:381": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"398:382",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"398:382": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"398:376",
0
],
"on_true": [
"398:380",
0
],
"switch": [
"398:383",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"398:383": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": True
},
"_meta": {
"title": "Boolean (Enable Prompt Enhance)"
}
},
"398:384": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"398:385": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ltx-2.5-video-vae-bf16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"398:386": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ltx-2.5-audio-vae-bf16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"398:387": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors",
"device": "default",
"type": "ltxv"
},
"_meta": {
"title": "Load CLIP"
}
},
"398:388": {
"class_type": "LTXVDualCFGGuider",
"inputs": {
"audio_cfg": 1,
"model": [
"398:384",
0
],
"negative": [
"398:365",
1
],
"positive": [
"398:365",
0
],
"video_cfg": 1
},
"_meta": {
"title": "LTXV Dual CFG Guider"
}
},
"398:391": {
"class_type": "LTXVDualCFGGuider",
"inputs": {
"audio_cfg": 1,
"model": [
"398:384",
0
],
"negative": [
"398:365",
1
],
"positive": [
"398:365",
0
],
"video_cfg": 1
},
"_meta": {
"title": "LTXV Dual CFG Guider"
}
},
"398:393": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "gemma4_e2b_it_bf16.safetensors",
"device": "default",
"type": "ltxv"
},
"_meta": {
"title": "Load CLIP"
}
},
"398:396": {
"class_type": "ManualSigmas",
"inputs": {
"sigmas": "0.85, 0.7250, 0.4219, 0.0"
},
"_meta": {
"title": "ManualSigmas"
}
},
"398:397": {
"class_type": "ManualSigmas",
"inputs": {
"sigmas": "1.0, 0.99375, 0.9875, 0.98125, 0.975, 0.909375, 0.725, 0.421875, 0.0"
},
"_meta": {
"title": "ManualSigmas"
}
}
})
workflow.set_input("395", "image", client.assets.from_url("https://comfy.org/catalog-media/c7c6e297-c2be-4973-b40d-6e5b81b8790c/fc248d53-6694-4fa1-a96f-02529c17a9fe"))
# 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("75"):
output.to_file(output.name)