# 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({
"2": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/LTX-2.5_t2v",
"format": "auto",
"format.codec": "auto",
"video": [
"3",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"3": {
"class_type": "LtxApi25TextToVideo",
"inputs": {
"model": "LTX-2.5 (Pro)",
"model.duration": "5",
"model.fps": "25",
"model.generate_audio": True,
"model.resolution": "1280x720",
"prompt": "CLOSE-UP: A man in a rumpled shirt stands by an apartment window at night, phone pressed to his ear, the city lights blurring beyond the glass, his own reflection ghosting beside him. He listens for a long moment, then says quietly, \"I know I should have called.\" He pauses, rubs his forehead, and continues, \"I'm sorry. I just...\" Another pause, his voice dropping, \"I didn't know what to say.\" He listens again, a small tired smile forming, and finally says, \"Yeah. Yeah, I'd like that.\" The camera slowly pushes in on his face as he ends the call and lowers the phone, the city hum and a distant siren filling the silence, his reflection staring back at him from the glass. No text, no black frames.\n",
"seed": 42
},
"_meta": {
"title": "LTX 2.5 Text To Video"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)