# 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({
"16": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"19",
1
],
"bit_depth": 8,
"chroma_subsampling": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"19",
2
],
"images": [
"15:4",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"17": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/SeedVR2",
"format": "auto",
"format.codec": "auto",
"video": [
"16",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"18": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"19": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"18",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"20": {
"class_type": "ImageScale",
"inputs": {
"crop": "center",
"height": 720,
"image": [
"22",
0
],
"upscale_method": "lanczos",
"width": 1280
},
"_meta": {
"title": "Upscale Image"
}
},
"22": {
"class_type": "ImageFromBatch",
"inputs": {
"batch_index": 0,
"image": [
"19",
0
],
"length": 96
},
"_meta": {
"title": "Get Image from Batch"
}
},
"15:4": {
"class_type": "SeedVR2VideoUpscaler",
"inputs": {
"batch_size": 5,
"color_correction": "lab",
"dit": [
"15:5",
0
],
"enable_debug": False,
"image": [
"20",
0
],
"input_noise_scale": 0,
"latent_noise_scale": 0,
"max_resolution": 0,
"offload_device": "cpu",
"prepend_frames": 0,
"resolution": 1080,
"seed": 825616700,
"temporal_overlap": 0,
"uniform_batch_size": False,
"vae": [
"15:6",
0
]
},
"_meta": {
"title": "SeedVR2 Video Upscaler (v2.5.24)"
}
},
"15:5": {
"class_type": "SeedVR2LoadDiTModel",
"inputs": {
"attention_mode": "sdpa",
"blocks_to_swap": 0,
"cache_model": False,
"device": "cuda:0",
"model": "seedvr2_ema_7b_fp16.safetensors",
"offload_device": "none",
"swap_io_components": False
},
"_meta": {
"title": "SeedVR2 (Down)Load DiT Model"
}
},
"15:6": {
"class_type": "SeedVR2LoadVAEModel",
"inputs": {
"cache_model": False,
"decode_tile_overlap": 128,
"decode_tile_size": 1024,
"decode_tiled": False,
"device": "cuda:0",
"encode_tile_overlap": 128,
"encode_tile_size": 1024,
"encode_tiled": False,
"model": "ema_vae_fp16.safetensors",
"offload_device": "none",
"tile_debug": "false"
},
"_meta": {
"title": "SeedVR2 (Down)Load VAE Model"
}
}
})
workflow.set_input("18", "file", client.assets.from_url("https://comfy.org/catalog-media/6709c537-e41f-4cf0-bbd4-42d8a4bed62b/ed7731ac-5cc7-444a-82d9-7306926755f6"))
# 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("17"):
output.to_file(output.name)