# 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({
"3": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"4": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/Topaz",
"format": "auto",
"format.codec": "auto",
"video": [
"5",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"5": {
"class_type": "TopazVideoEnhance",
"inputs": {
"dynamic_compression_level": "Low",
"interpolation_duplicate": False,
"interpolation_duplicate_threshold": 0.01,
"interpolation_enabled": False,
"interpolation_frame_rate": 60,
"interpolation_model": "apo-8",
"interpolation_slowmo": 1,
"upscaler_creativity": "low",
"upscaler_enabled": True,
"upscaler_model": "Starlight Precise 2.5",
"upscaler_resolution": "FullHD (1080p)",
"video": [
"3",
0
]
},
"_meta": {
"title": "Topaz Video Enhance (Legacy)"
}
}
})
workflow.set_input("3", "file", client.assets.from_url("https://comfy.org/catalog-media/0885456b-e541-42e6-ad1c-a4fc8119a8b0/1621ffb0-3702-4e21-9e99-d8a9cfae3e89"))
# 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("4"):
output.to_file(output.name)