# 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": "RTXVideoSuperResolution",
"inputs": {
"image_encoding": "8-bit RGB",
"images": [
"7",
0
],
"quality": "ULTRA",
"resize_type": "scale by multiplier",
"resize_type.scale": 2,
"strength": 1
},
"_meta": {
"title": "RTX Video Super Resolution"
}
},
"6": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"7": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"6",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"8": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"7",
1
],
"bit_depth": "auto",
"chroma_subsampling": "none",
"codec": "none",
"color_space": "HDR",
"fps": [
"13",
0
],
"images": [
"11",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"9": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"8",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"10": {
"class_type": "RTXVideoFrameGeneration",
"inputs": {
"automatic_shot_change_detection": True,
"generation_type": "frame rate multiplier",
"generation_type.multiplier": [
"12",
0
],
"image_encoding": "8-bit RGB",
"images": [
"1",
0
],
"mode": "MEDIUM",
"shot_change": False
},
"_meta": {
"title": "RTX Video Frame Generation"
}
},
"11": {
"class_type": "RTXTrueHDR",
"inputs": {
"contrast": 100,
"debanding": True,
"images": [
"10",
0
],
"luminance": 650,
"middle_gray": 50,
"output_colorspace": "HDR",
"saturation": 100
},
"_meta": {
"title": "RTX TrueHDR"
}
},
"12": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 2
},
"_meta": {
"title": "Multiplier"
}
},
"13": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a * b",
"values.a": [
"7",
2
],
"values.b": [
"12",
0
]
},
"_meta": {
"title": "Math Expression"
}
}
})
workflow.set_input("6", "file", client.assets.from_url("https://comfy.org/catalog-media/cf3977fb-2de3-4c1d-b26f-e8da139e70f9/0564eb93-8f1d-4c83-b786-2e03662983b6"))
# 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("9"):
output.to_file(output.name)