# 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({
"54": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "ComfyUI",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"50:27",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
},
"55": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "ComfyUI",
"format": "exr",
"format.bit_depth": "16-bit float",
"format.input_color_space": "linear ACEScg",
"images": [
"57",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
},
"56": {
"class_type": "RTXTrueHDR",
"inputs": {
"contrast": 100,
"debanding": True,
"images": [
"50:27",
0
],
"luminance": 650,
"middle_gray": 50,
"output_colorspace": "HDR",
"saturation": 100
},
"_meta": {
"title": "RTX TrueHDR"
}
},
"57": {
"class_type": "ImageColorSpace",
"inputs": {
"destination": "linear ACEScg",
"image": [
"56",
0
],
"source": "HDR"
},
"_meta": {
"title": "Convert Image Color Space"
}
},
"508": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image1_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"509": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": "",
"string_a": "Transform this set of images into an equirectangular 360 panorama. Scene:",
"string_b": [
"510",
0
]
},
"_meta": {
"title": "Concatenate Text"
}
},
"510": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "A photograph of the interior of an abandoned brick building. The concrete floor is buried under drifts of sand and dirt littered with splintered wooden planks, curled debris and scattered bricks, and soft overcast daylight spills in through rows of grimy windows and open bays where green foliage presses in from outside. Shot on a DSLR."
},
"_meta": {
"title": "Input Text (Prompt)"
}
},
"507:451": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_2.1_int8_convrot.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"507:453": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen3vl_8b_int8_convrot.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"507:454": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_2.1_vae_bf16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"507:456": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 1024,
"width": 2048
},
"_meta": {
"title": "Empty Latent Image"
}
},
"507:457": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"507:458",
0
],
"vae": [
"507:454",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"507:458": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"507:468",
0
],
"model": [
"507:469",
0
],
"negative": [
"507:474",
1
],
"positive": [
"507:474",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 42,
"steps": 25
},
"_meta": {
"title": "KSampler"
}
},
"507:468": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"507:474",
2
],
"on_true": [
"507:456",
0
],
"switch": True
},
"_meta": {
"title": "If/Else Switch"
}
},
"507:469": {
"class_type": "QwenImage21Cache",
"inputs": {
"device": "auto",
"dtype": "default",
"model": [
"507:503",
0
]
},
"_meta": {
"title": "Qwen Image 2.1 Cache"
}
},
"507:474": {
"class_type": "TextEncodeQwenImage21",
"inputs": {
"clip": [
"507:453",
0
],
"images.image_1": [
"508",
0
],
"negative_prompt": "",
"prompt": [
"509",
0
],
"resolution": 0,
"vae": [
"507:454",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image 2.1"
}
},
"507:503": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Gogodr__qwen-image-21-edit-pano360-lora__pano360_qwen21_edit_v1.safetensors",
"model": [
"507:451",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"50:21": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"507:457",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"50:22": {
"class_type": "SeedVR2LoadVAEModel",
"inputs": {
"cache_model": False,
"decode_tile_overlap": 128,
"decode_tile_size": 1024,
"decode_tiled": True,
"device": "cuda:0",
"encode_tile_overlap": 128,
"encode_tile_size": 1024,
"encode_tiled": True,
"model": "ema_vae_fp16.safetensors",
"offload_device": "none",
"tile_debug": "false"
},
"_meta": {
"title": "SeedVR2 (Down)Load VAE Model"
}
},
"50:25": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"50:43",
0
],
"b": [
"50:30",
0
],
"value": "a*b"
},
"_meta": {
"title": "Upscale to Shortest Edge (pixels)"
}
},
"50:27": {
"class_type": "SeedVR2VideoUpscaler",
"inputs": {
"batch_size": 1,
"color_correction": "lab",
"dit": [
"50:28",
0
],
"enable_debug": False,
"image": [
"507:457",
0
],
"input_noise_scale": 0,
"latent_noise_scale": 0,
"max_resolution": 0,
"offload_device": "cpu",
"prepend_frames": 0,
"resolution": [
"50:25",
0
],
"seed": 1,
"temporal_overlap": 0,
"uniform_batch_size": False,
"vae": [
"50:22",
0
]
},
"_meta": {
"title": "SeedVR2 Video Upscaler (v2.5.24)"
}
},
"50:28": {
"class_type": "SeedVR2LoadDiTModel",
"inputs": {
"attention_mode": "sdpa",
"blocks_to_swap": 0,
"cache_model": False,
"device": "cuda:0",
"model": "seedvr2_ema_3b_fp16.safetensors",
"offload_device": "cpu",
"swap_io_components": False
},
"_meta": {
"title": "SeedVR2 (Down)Load DiT Model"
}
},
"50:30": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 2
},
"_meta": {
"title": "Upscale Factor"
}
},
"50:40": {
"class_type": "ImpactCompare",
"inputs": {
"a": [
"50:21",
0
],
"b": [
"50:21",
1
],
"cmp": "a <= b"
},
"_meta": {
"title": "ImpactCompare"
}
},
"50:43": {
"class_type": "LayerUtility: If ",
"inputs": {
"if_condition": [
"50:40",
0
],
"when_FALSE": [
"50:21",
1
],
"when_TRUE": [
"50:21",
0
]
},
"_meta": {
"title": "IfElse"
}
}
})
workflow.set_input("508", "image", client.assets.from_url("https://comfy.org/catalog-media/8312b488-282d-4ee8-9905-a16fb4214132/2a126bb1-ccfe-4fda-be7f-469194ab4188"))
# 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("54"):
output.to_file(output.name)