# 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({
"31": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_first_frame_FILENAME"
},
"_meta": {
"title": "Load First Frame"
}
},
"39": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_last_frame_FILENAME"
},
"_meta": {
"title": "Load Last Frame"
}
},
"68": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ltx2.5_flf2v",
"format": "auto",
"format.codec": "auto",
"video": [
"251:218",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"251:195": {
"class_type": "LTXVPreprocess",
"inputs": {
"image": [
"251:214",
0
],
"img_compression": 18
},
"_meta": {
"title": "LTXV Preprocess"
}
},
"251:196": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 873293130933086
},
"_meta": {
"title": "RandomNoise"
}
},
"251:197": {
"class_type": "LTXVEmptyLatentAudio",
"inputs": {
"audio_vae": [
"251:227",
0
],
"batch_size": 1,
"frame_rate": [
"251:205",
0
],
"frames_number": [
"251:226",
1
]
},
"_meta": {
"title": "Empty LTXV Latent Audio"
}
},
"251:198": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 5
},
"_meta": {
"title": "Duration"
}
},
"251:199": {
"class_type": "LTXVPreprocess",
"inputs": {
"image": [
"251:213",
0
],
"img_compression": 18
},
"_meta": {
"title": "LTXV Preprocess"
}
},
"251:200": {
"class_type": "LTXVCropGuides",
"inputs": {
"latent": [
"251:221",
0
],
"negative": [
"251:204",
1
],
"positive": [
"251:204",
0
]
},
"_meta": {
"title": "LTXVCropGuides"
}
},
"251:201": {
"class_type": "EmptyLTXVLatentVideo",
"inputs": {
"batch_size": 1,
"height": [
"251:203",
1
],
"length": [
"251:226",
1
],
"width": [
"251:203",
0
]
},
"_meta": {
"title": "Empty LTXV Latent Video"
}
},
"251:202": {
"class_type": "LTXVConditioning",
"inputs": {
"frame_rate": [
"251:212",
0
],
"negative": [
"251:217",
0
],
"positive": [
"251:222",
0
]
},
"_meta": {
"title": "LTXVConditioning"
}
},
"251:203": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"251:213",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"251:204": {
"class_type": "LTXVAddGuide",
"inputs": {
"frame_idx": -1,
"image": [
"251:195",
0
],
"latent": [
"251:206",
2
],
"negative": [
"251:206",
1
],
"positive": [
"251:206",
0
],
"strength": 0.7,
"vae": [
"251:229",
0
]
},
"_meta": {
"title": "LTXVAddGuide"
}
},
"251:205": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 24
},
"_meta": {
"title": "Frame Rate(int)"
}
},
"251:206": {
"class_type": "LTXVAddGuide",
"inputs": {
"frame_idx": 0,
"image": [
"251:199",
0
],
"latent": [
"251:201",
0
],
"negative": [
"251:202",
1
],
"positive": [
"251:202",
0
],
"strength": 0.7,
"vae": [
"251:229",
0
]
},
"_meta": {
"title": "LTXVAddGuide"
}
},
"251:208": {
"class_type": "SamplerEulerAncestral",
"inputs": {
"eta": 0,
"s_noise": 1
},
"_meta": {
"title": "SamplerEulerAncestral"
}
},
"251:210": {
"class_type": "LTXVConcatAVLatent",
"inputs": {
"audio_latent": [
"251:197",
0
],
"video_latent": [
"251:204",
2
]
},
"_meta": {
"title": "Concat AV Latent"
}
},
"251:211": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"251:235",
0
],
"latent_image": [
"251:210",
0
],
"noise": [
"251:196",
0
],
"sampler": [
"251:208",
0
],
"sigmas": [
"251:239",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"251:212": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"251:205",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"251:213": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"31",
0
],
"resize_type": "scale dimensions",
"resize_type.crop": "center",
"resize_type.height": [
"251:216",
0
],
"resize_type.width": [
"251:215",
0
],
"scale_method": "nearest-exact"
},
"_meta": {
"title": "Resize Image/Mask"
}
},
"251:214": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"39",
0
],
"resize_type": "scale dimensions",
"resize_type.crop": "center",
"resize_type.height": [
"251:216",
0
],
"resize_type.width": [
"251:215",
0
],
"scale_method": "nearest-exact"
},
"_meta": {
"title": "Resize Image/Mask"
}
},
"251:215": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 1280
},
"_meta": {
"title": "Width"
}
},
"251:216": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 720
},
"_meta": {
"title": "height"
}
},
"251:217": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"251:228",
0
],
"text": "blurry, out of focus, overexposed, underexposed, low contrast, washed out colors, excessive noise, grainy texture, poor lighting, flickering, motion blur, distorted proportions, unnatural skin tones, deformed facial features, asymmetrical face, missing facial features, extra limbs, disfigured hands, wrong hand count, artifacts around text, unreadable text on shirt or hat, incorrect lettering on cap (“PNTR”), incorrect t-shirt slogan (“JUST DO IT”), missing microphone, misplaced microphone, inconsistent perspective, camera shake, incorrect depth of field, background too sharp, background clutter, distracting reflections, harsh shadows, inconsistent lighting direction, color banding, cartoonish rendering, 3D CGI look, unrealistic materials, uncanny valley effect, incorrect ethnicity, wrong gender, exaggerated expressions, smiling, laughing, exaggerated sadness, wrong gaze direction, eyes looking at camera, mismatched lip sync, silent or muted audio, distorted voice, robotic voice, echo, background noise, off-sync audio, missing sniff sounds, incorrect dialogue, added dialogue, repetitive speech, jittery movement, awkward pauses, incorrect timing, unnatural transitions, inconsistent framing, tilted camera, missing door or shelves, missing shallow depth of field, flat lighting, inconsistent tone, cinematic oversaturation, stylized filters, or AI artifacts."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"251:218": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"251:220",
0
],
"bit_depth": 8,
"codec": "none",
"color_space": "sRGB",
"fps": [
"251:212",
0
],
"images": [
"251:219",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"251:219": {
"class_type": "VAEDecodeTiled",
"inputs": {
"overlap": 64,
"samples": [
"251:200",
2
],
"temporal_overlap": 64,
"temporal_size": 4096,
"tile_size": 768,
"vae": [
"251:229",
0
]
},
"_meta": {
"title": "VAE Decode (Tiled)"
}
},
"251:220": {
"class_type": "LTXVAudioVAEDecode",
"inputs": {
"audio_vae": [
"251:227",
0
],
"samples": [
"251:221",
1
]
},
"_meta": {
"title": "LTXV Audio VAE Decode"
}
},
"251:221": {
"class_type": "LTXVSeparateAVLatent",
"inputs": {
"av_latent": [
"251:211",
1
]
},
"_meta": {
"title": "Separate AV Latent"
}
},
"251:222": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"251:228",
0
],
"text": [
"251:248",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"251:226": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a * b + 1",
"values.a": [
"251:198",
0
],
"values.b": [
"251:205",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"251:227": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ltx-2.5-audio-vae-bf16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"251:228": {
"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"
}
},
"251:229": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ltx-2.5-video-vae-bf16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"251:230": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"251:235": {
"class_type": "LTXVDualCFGGuider",
"inputs": {
"audio_cfg": 1,
"model": [
"251:230",
0
],
"negative": [
"251:204",
1
],
"positive": [
"251:204",
0
],
"video_cfg": 1
},
"_meta": {
"title": "LTXV Dual CFG Guider"
}
},
"251:239": {
"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"
}
},
"251:246": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "gemma4_e2b_it_bf16.safetensors",
"device": "default",
"type": "ltxv"
},
"_meta": {
"title": "Load CLIP"
}
},
"251:247": {
"class_type": "TextGenerateLTX2Prompt",
"inputs": {
"clip": [
"251:246",
0
],
"image": [
"251:199",
0
],
"max_length": 600,
"mtp": "auto",
"prompt": [
"251:252",
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"
}
},
"251:248": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"251:252",
0
],
"on_true": [
"251:247",
0
],
"switch": [
"251:250",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"251:249": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"251:248",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"251:250": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": True
},
"_meta": {
"title": "Boolean (Enable Prompt Enhance)"
}
},
"251:252": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "The video opens low on the black water, the colossal closed bud standing motionless under the stormy midnight sky while thin fog crawls across the surface and a cold wind hisses. A single beam of moonlight shifts across the frosted outer petals. With a deep creaking sound, the bud begins to loosen: the outer petals peel back one by one, slowly and heavily, shedding flakes of frost into the water with soft splashes. Ripples spread outward in rings, catching faint cyan glints from below. As the inner petals unfurl, a warm amber glow swells from the heart of the flower, rising into the mist and lighting the undersides of the petals and the nearby basalt rocks. The camera holds steady at water level, then drifts slightly closer as the flower opens fully and its glow hums softly."
},
"_meta": {
"title": "Prompt"
}
}
})
workflow.set_input("31", "image", client.assets.from_url("https://comfy.org/catalog-media/4f6040be-625a-4b93-a379-fe59a630c054/a4ded0e5-806b-42b3-ae29-8ebd7edc22f1"))
workflow.set_input("39", "image", client.assets.from_url("https://comfy.org/catalog-media/d12742d8-ff7e-4fd7-a6b6-dd80ef65305c/696609a3-c17b-4b2e-af69-29bb504a5295"))
# 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("68"):
output.to_file(output.name)