# 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({
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38",
0
],
"text": "An elderly nomad in a thick indigo wool coat with a shearling collar sits on a wet granite ledge high above a misty glacial valley at dawn. He slowly lifts his head, turns to look out over the valley, and rolls the wooden prayer beads between his weathered fingers while the wind lifts strands of his silver hair and the fleece of his collar. Below him, banks of fog drift slowly across the braided rivers and the first rose-gold light creeps over the distant snowy peaks. The camera begins close on his face and slowly pulls back and rises to reveal the vast valley stretching away behind him. Cinematic, natural motion, soft morning light, realistic detail."
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38",
0
],
"text": "low quality, worst quality, deformed, distorted, disfigured, motion smear, motion artifacts, fused fingers, bad anatomy, weird hand, ugly"
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"72",
0
],
"vae": [
"44",
2
]
},
"_meta": {
"title": "VAE Decode"
}
},
"38": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "t5xxl_fp16.safetensors",
"device": "default",
"type": "ltxv"
},
"_meta": {
"title": "Load CLIP"
}
},
"44": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "ltx-video-2b-v0.9.5.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"69": {
"class_type": "LTXVConditioning",
"inputs": {
"frame_rate": 25,
"negative": [
"77",
1
],
"positive": [
"77",
0
]
},
"_meta": {
"title": "LTXVConditioning"
}
},
"71": {
"class_type": "LTXVScheduler",
"inputs": {
"base_shift": 0.95,
"latent": [
"77",
2
],
"max_shift": 2.05,
"steps": 30,
"stretch": True,
"terminal": 0.1
},
"_meta": {
"title": "LTXVScheduler"
}
},
"72": {
"class_type": "SamplerCustom",
"inputs": {
"add_noise": True,
"cfg": 3,
"latent_image": [
"77",
2
],
"model": [
"44",
0
],
"negative": [
"69",
1
],
"noise_seed": 712395695050634,
"positive": [
"69",
0
],
"sampler": [
"73",
0
],
"sigmas": [
"71",
0
]
},
"_meta": {
"title": "SamplerCustom"
}
},
"73": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"77": {
"class_type": "LTXVImgToVideo",
"inputs": {
"batch_size": 1,
"height": 576,
"image": [
"78",
0
],
"length": 97,
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"strength": 0.15,
"vae": [
"44",
2
],
"width": 1024
},
"_meta": {
"title": "LTXVImgToVideo"
}
},
"78": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"80": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": 24,
"images": [
"8",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"81": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"80",
0
]
},
"_meta": {
"title": "Save Video"
}
}
})
workflow.set_input("78", "image", client.assets.from_url("https://comfy.org/catalog-media/1dfd11b2-7888-47c7-a563-491e97037d2a/0330a0b5-2c69-4df0-93d6-d07f707c5423"))
# 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("81"):
output.to_file(output.name)