# 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({
"94": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"95",
0
],
"sampling": "flow",
"shift": 3
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"95": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "z_image_turbo_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"96": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_4b.safetensors",
"device": "default",
"type": "lumina2"
},
"_meta": {
"title": "Load CLIP"
}
},
"97": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"98": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"102",
0
],
"vae": [
"97",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"99": {
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"103",
0
]
},
"_meta": {
"title": "Conditioning Zero Out"
}
},
"100": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Z-Image-Turbo",
"images": [
"98",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"101": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 1920,
"width": 1080
},
"_meta": {
"title": "Empty Latent Image"
}
},
"102": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"101",
0
],
"model": [
"94",
0
],
"negative": [
"99",
0
],
"positive": [
"103",
0
],
"sampler_name": "res_multistep",
"scheduler": "simple",
"seed": 222678399973641,
"steps": 8
},
"_meta": {
"title": "KSampler"
}
},
"103": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"96",
0
],
"text": "Editorial shot: On a volcanic black sand beach with a dark overcast sky.\n\nLow side-angle: Male model is in a deep squat, knees wide, head resting in one hand with a brooding, sharp gaze.\n\nHair: Ultra-short platinum blonde buzz cut.\n\nWardrobe: light-blue transparent oval sunglasses, oversized black wool chunky-knit sweater, baggy cargo trousers, climbing shoes. \n\nLighting: Theatrical cold blue moonlighting contrasted by a single sharp, warm orange spotlight on the face. Shot on Fujifilm GFX 100S, 110mm f/2 lens\n\nVibe: Paganism, futuristic tech-wear."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)