# 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({
"298": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"747",
0
],
"vae": [
"710",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"694": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 3.5,
"model": [
"701",
0
],
"negative": [
"749",
0
],
"positive": [
"748",
0
]
},
"_meta": {
"title": "CFG Guider"
}
},
"700": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"701": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"731",
0
],
"sampling": "flow",
"shift": 1
},
"_meta": {
"title": "Flow Shift"
}
},
"710": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"718": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 68346347456896
},
"_meta": {
"title": "SEED"
}
},
"731": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "Chroma1-HD-fp8mixed.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"733": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "t5xxl_fp8_e4m3fn_scaled.safetensors",
"device": "default",
"type": "chroma"
},
"_meta": {
"title": "Load CLIP"
}
},
"734": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"701",
0
],
"scheduler": "beta",
"steps": 26
},
"_meta": {
"title": "BasicScheduler"
}
},
"737": {
"class_type": "EmptySD3LatentImage",
"inputs": {
"batch_size": 1,
"height": 768,
"width": 1344
},
"_meta": {
"title": "EmptySD3LatentImage"
}
},
"740": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"298",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"741": {
"class_type": "T5TokenizerOptions",
"inputs": {
"clip": [
"733",
0
],
"min_length": 0,
"min_padding": 0
},
"_meta": {
"title": "T5 Tokenizer Options"
}
},
"747": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"694",
0
],
"latent_image": [
"737",
0
],
"noise": [
"718",
0
],
"sampler": [
"700",
0
],
"sigmas": [
"734",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"748": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"741",
0
],
"text": "A documentary wildlife photograph captures an intimate, low-angle close-up of a mature silverback mountain gorilla’s weathered face, photographed with a 400mm f/2.8 prime telephoto lens. The subject rests slightly off-center in the deep bamboo forest of the Virunga Mountains at dawn. Soft, directional morning sunlight filters through heavy mountain mist, illuminating individual coarse black hairs, silver-tipped follicles along the temples, and intricate leathery creases surrounding deep-set amber eyes. Tiny water droplets glisten across the prominent brow ridge and broad, textured nostrils. The shallow depth of field melts the background into a silky, diffuse expanse of damp emerald foliage, suspended fog, and cool shadows stretching into the distance across the negative space beside the primate's contemplative profile."
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"749": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"741",
0
],
"text": "This low quality greyscale unfinished sketch is inaccurate and flawed. The image is very blurred and lacks detail with excessive chromatic aberrations and artifacts. The image is overly saturated with excessive bloom. It has a toony aesthetic with bold outlines and flat colors. "
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
}
})
# 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("740"):
output.to_file(output.name)