# 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({
"1": {
"class_type": "LtxApiVideoCompositing",
"inputs": {
"prompt": "Blend the warrior into the golden grassland at sunset. The low sun behind his left shoulder rims the fur, his hair and his beard with warm light while his face picks up warm bounce, tall dry grass in the foreground crosses the bottom edge of frame where his body continues out of shot, and his colour grades to the golden light of the field. Keep his face, beard, braids and the studded armour detail unchanged, with no colour patches or green tint.",
"seed": 7,
"video": [
"3",
0
]
},
"_meta": {
"title": "LTX Video Compositing"
}
},
"3": {
"class_type": "LoadVideo",
"inputs": {
"file": "warrior_rough_composite_grassland.mp4"
},
"_meta": {
"title": "Load Video"
}
},
"4": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/LTX_VFX_compositing",
"format": "auto",
"format.codec": "auto",
"video": [
"1",
0
]
},
"_meta": {
"title": "Save Video"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)