# 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": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2511_fp8mixed.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"3": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2511-SYSTMS-QWEN_EDIT_ACTION_V1.safetensors",
"model": [
"1",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"4": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2511-Lightning-8steps-V1.0-fp32.safetensors",
"model": [
"3",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"5": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"6": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"8": {
"class_type": "QwenEditTextEncode_EditUtils",
"inputs": {
"clip": [
"6",
0
],
"image1": [
"24",
0
],
"prompt": "action the red panda. Turn the red panda on the frosty branch into a collectible articulated action figure toy, keeping its pose, its rust-orange fur pattern, its striped tail and the winter mountain setting. Give it smooth sculpted plastic fur with painted details, visible ball joints at the shoulders, elbows, hips and knees, glossy painted eyes and a slightly oversized head like a premium toy. The branch becomes a small sculpted display base with molded snow and icicles. Keep the warm sunset light raking across the scene, with crisp toy-photography detail, a shallow depth of field and the snowy peaks softly blurred behind it, so it looks like a real figure photographed on location.",
"ref_longest_edge": [
"27",
0
],
"vae": [
"5",
0
]
},
"_meta": {
"title": "EditUtils: Qwen Edit Text Encode lrzjason"
}
},
"9": {
"class_type": "QwenEditTextEncode_EditUtils",
"inputs": {
"clip": [
"6",
0
],
"image1": [
"24",
0
],
"prompt": "",
"ref_longest_edge": [
"27",
0
],
"vae": [
"5",
0
]
},
"_meta": {
"title": "EditUtils: Qwen Edit Text Encode lrzjason"
}
},
"10": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"11": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"13",
0
],
"latent_image": [
"8",
1
],
"noise": [
"12",
0
],
"sampler": [
"14",
0
],
"sigmas": [
"15",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"12": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 1111810674705380
},
"_meta": {
"title": "RandomNoise"
}
},
"13": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 1,
"model": [
"4",
0
],
"negative": [
"9",
0
],
"positive": [
"8",
0
]
},
"_meta": {
"title": "CFG Guider"
}
},
"14": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "ddim"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"15": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"4",
0
],
"scheduler": "beta57",
"steps": 8
},
"_meta": {
"title": "BasicScheduler"
}
},
"16": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"11",
0
],
"vae": [
"5",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"17": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "SYSTMS_ACTION",
"images": [
"25",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"24": {
"class_type": "ResizeImagesByLongerEdge",
"inputs": {
"images": [
"10",
0
],
"longer_edge": [
"27",
0
]
},
"_meta": {
"title": "Resize Images by Longer Edge (DEPRECATED)"
}
},
"25": {
"class_type": "ImageCrop+",
"inputs": {
"height": [
"26",
1
],
"image": [
"16",
0
],
"position": "top-center",
"width": [
"26",
0
],
"x_offset": 0,
"y_offset": 0
},
"_meta": {
"title": "🔧 Image Crop"
}
},
"26": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"24",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"27": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 1344
},
"_meta": {
"title": "IMAGE SIZE: LONGEST EDGE"
}
}
})
workflow.set_input("10", "image", client.assets.from_url("https://comfy.org/catalog-media/b1ec95de-a2ff-4bc2-aba5-4b457ce1fd28/3f1da4aa-0207-4fdd-a635-61053fe5f4ad"))
# 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)