# 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({
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"19",
0
],
"vae": [
"15",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"11": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"45",
0
],
"text": "masterpiece, best quality, score_7, safe, anime, cyborg in profile, his gaze tilted upward toward a dense, chaotic wall of glowing computer monitors, high-contrast glow of cyan, violet, and deep indigo, casting scrolling data, clean line art, detailed background, key visual composition"
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"12": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"45",
0
],
"text": "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"15": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"19": {
"class_type": "KSampler",
"inputs": {
"cfg": 4,
"denoise": 1,
"latent_image": [
"28",
0
],
"model": [
"44",
0
],
"negative": [
"12",
0
],
"positive": [
"11",
0
],
"sampler_name": "er_sde",
"scheduler": "simple",
"seed": 897905614436812,
"steps": 30
},
"_meta": {
"title": "KSampler"
}
},
"28": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": [
"60",
1
],
"width": [
"60",
0
]
},
"_meta": {
"title": "Empty Latent Image"
}
},
"44": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "anima-preview2.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"45": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_06b_base.safetensors",
"device": "default",
"type": "stable_diffusion"
},
"_meta": {
"title": "Load CLIP"
}
},
"46": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "anime",
"images": [
"8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"60": {
"class_type": "ResolutionSelector",
"inputs": {
"aspect_ratio": "4:3 (Standard)",
"megapixels": 1,
"multiple": 8
},
"_meta": {
"title": "Resolution Selector"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)