# 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": "SaveVideo",
"inputs": {
"filename_prefix": "video/flux3_t2v",
"format": "auto",
"format.codec": "auto",
"video": [
"13",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"13": {
"class_type": "Flux3TextToVideoNode",
"inputs": {
"aspect_ratio": "16:9",
"duration": "auto",
"generate_audio": True,
"prompt": "A monolithic, stepped spire constructed from dark iridescent obsidian and oxidized verdigris bronze rises alone from a vast, wind-scoured crimson desert under a burning amber sunset. Heat shimmer ripples across the sunbaked cracked clay, while violent gusts of wind whip plumes of fine vermilion sand across the undulating dune crests. The camera executes a slow, cinematic drone orbit, climbing gradually higher as golden-hour sunlight flares intensely off the building’s razor-sharp glass-and-copper edges, casting a towering, lengthening shadow across the arid expanse. The audio is dominated by the deep, hollow drone of desert gale howling over metallic vents, punctuated by the sharp, continuous hissing of drifting sand grains scraping against polished stone.",
"resolution": "720p",
"safety_tolerance": 2,
"seed": 42
},
"_meta": {
"title": "Flux 3 Text to Video"
}
}
})
# 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("6"):
output.to_file(output.name)