# 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({
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Qwen_Edit_2511",
"images": [
"89:8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"41": {
"class_type": "LoadImage",
"inputs": {
"image": "inflation_lora_input.png"
},
"_meta": {
"title": "Load Image"
}
},
"89:10": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"89:12": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2511_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"89:61": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"89:64": {
"class_type": "CFGNorm",
"inputs": {
"model": [
"89:67",
0
],
"pre_cfg": False,
"strength": 1
},
"_meta": {
"title": "CFGNorm"
}
},
"89:65": {
"class_type": "KSampler",
"inputs": {
"cfg": 4,
"denoise": 1,
"latent_image": [
"89:75",
0
],
"model": [
"89:64",
0
],
"negative": [
"89:71",
0
],
"positive": [
"89:70",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 1123448499955428,
"steps": 40
},
"_meta": {
"title": "KSampler"
}
},
"89:67": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"89:90",
0
],
"sampling": "flow",
"shift": 3.1
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"89:68": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"89:61",
0
],
"image1": [
"89:88",
0
],
"prompt": "inflate the man",
"vae": [
"89:10",
0
]
},
"_meta": {
"title": "TextEncodeQwenImageEditPlus (Positive)"
}
},
"89:69": {
"class_type": "TextEncodeQwenImageEditPlus",
"inputs": {
"clip": [
"89:61",
0
],
"image1": [
"89:88",
0
],
"prompt": "",
"vae": [
"89:10",
0
]
},
"_meta": {
"title": "Text Encode Qwen Image Edit Plus"
}
},
"89:70": {
"class_type": "FluxKontextMultiReferenceLatentMethod",
"inputs": {
"conditioning": [
"89:68",
0
],
"reference_latents_method": "index_timestep_zero"
},
"_meta": {
"title": "Edit Model Reference Method"
}
},
"89:71": {
"class_type": "FluxKontextMultiReferenceLatentMethod",
"inputs": {
"conditioning": [
"89:69",
0
],
"reference_latents_method": "index_timestep_zero"
},
"_meta": {
"title": "Edit Model Reference Method"
}
},
"89:75": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"89:88",
0
],
"vae": [
"89:10",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"89:8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"89:65",
0
],
"vae": [
"89:10",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"89:88": {
"class_type": "FluxKontextImageScale",
"inputs": {
"image": [
"41",
0
]
},
"_meta": {
"title": "FluxKontextImageScale"
}
},
"89:90": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen_Image_Edit_2511-SYSTMS_INFL8.safetensors",
"model": [
"89:12",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)