# 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({
"43": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "PixelDiT",
"images": [
"44:15",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"46": {
"class_type": "ResolutionSelector",
"inputs": {
"aspect_ratio": "1:1 (Square)",
"megapixels": 1,
"multiple": 8
},
"_meta": {
"title": "Resolution Selector"
}
},
"44:15": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"44:42",
0
],
"vae": [
"44:16",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"44:16": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "pixel_space"
},
"_meta": {
"title": "Load VAE"
}
},
"44:2": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "pixeldit_1300m_1024px_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"44:30": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"44:9",
0
],
"text": "low quality, worst quality, over-saturated, blurry, deformed, watermark"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"44:31": {
"class_type": "EmptyChromaRadianceLatentImage",
"inputs": {
"batch_size": 1,
"height": [
"46",
1
],
"width": [
"46",
0
]
},
"_meta": {
"title": "EmptyChromaRadianceLatentImage"
}
},
"44:42": {
"class_type": "KSampler",
"inputs": {
"cfg": 4,
"denoise": 1,
"latent_image": [
"44:31",
0
],
"model": [
"44:2",
0
],
"negative": [
"44:30",
0
],
"positive": [
"44:6",
0
],
"sampler_name": "er_sde",
"scheduler": "simple",
"seed": 59233627785266,
"steps": 30
},
"_meta": {
"title": "KSampler"
}
},
"44:6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"44:9",
0
],
"text": "A surreal architectural scene featuring a woman in a flowing white dress walking away from the viewer through a narrow canyon of smooth, organic beige rock formations. The architecture resembles fluid sandstone or sculpted clay with undulating curves and soft edges. Bright sunlight streams from above, casting sharp shadows on the ground and illuminating the textured surfaces of the walls. The sky is a clear, deep blue visible at the top of the frame. The composition uses leading lines formed by the canyon walls to draw the eye toward the figure in the distance. High-quality photorealistic rendering with 8k resolution, cinematic lighting, dramatic contrast between light and shadow, and a sense of scale emphasizing the grandeur of the environment."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"44:9": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "gemma_2_2b_it_elm_bf16.safetensors",
"device": "default",
"type": "pixeldit"
},
"_meta": {
"title": "Load CLIP"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)