# 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": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"2": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Qwen_Edit_2511",
"images": [
"4:102",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"3": {
"class_type": "QwenMultiangleCameraNode",
"inputs": {
"camera_view": False,
"default_prompts": False,
"horizontal_angle": 45,
"image": [
"1",
0
],
"vertical_angle": 30,
"zoom": 5.7
},
"_meta": {
"title": "Qwen Multiangle Camera"
}
},
"4:100": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"4:93",
0
],
"image1": [
"4:106",
0
],
"prompt": "",
"vae": [
"4:95",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
},
"4:102": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"4:105",
0
],
"vae": [
"4:95",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"4:103": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"4:93",
0
],
"image1": [
"4:106",
0
],
"prompt": [
"3",
0
],
"vae": [
"4:95",
0
]
},
"_meta": {
"title": "TextEncodeQwenImageEditPlus (Positive)"
}
},
"4:104": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"4:106",
0
],
"vae": [
"4:95",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"4:105": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"4:104",
0
],
"model": [
"4:98",
0
],
"negative": [
"4:96",
0
],
"positive": [
"4:97",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 755111314014880,
"steps": 4
},
"_meta": {
"title": "KSampler"
}
},
"4:106": {
"class_type": "FluxKontextImageScale",
"inputs": {
"image": [
"1",
0
]
},
"_meta": {
"title": "FluxKontextImageScale"
}
},
"4:107": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors",
"model": [
"4:108",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"4:108": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2511_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"4:110": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "qwen-image-edit-2511-multiple-angles-lora.safetensors",
"model": [
"4:107",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"4:93": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"4:94": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"4:110",
0
],
"sampling": "flow",
"shift": 3.1
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"4:95": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"4:96": {
"class_type": "FluxKontextMultiReferenceLatentMethod",
"inputs": {
"conditioning": [
"4:100",
0
],
"reference_latents_method": "index_timestep_zero"
},
"_meta": {
"title": "Edit Model Reference Method"
}
},
"4:97": {
"class_type": "FluxKontextMultiReferenceLatentMethod",
"inputs": {
"conditioning": [
"4:103",
0
],
"reference_latents_method": "index_timestep_zero"
},
"_meta": {
"title": "Edit Model Reference Method"
}
},
"4:98": {
"class_type": "CFGNorm",
"inputs": {
"model": [
"4:94",
0
],
"pre_cfg": False,
"strength": 1
},
"_meta": {
"title": "CFGNorm"
}
}
})
workflow.set_input("1", "image", client.assets.from_url("https://comfy.org/catalog-media/3b0ef7a9-4a93-453e-9fce-32b6aa0fedbe/77e8af41-48bb-4103-a022-18a791445591"))
# 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("2"):
output.to_file(output.name)