# 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, A 1990s cyberpunk anime extreme close-up facial portrait centers on a genderless, fully mechanical cyborg head that dominates the frame. The synthetic face consists of segmented matte lavender-grey plating, industrial rivets, micro-seams, and intricate exposed circuitry. Thin glowing cables and illuminated fibre-optic wires plug directly into both optical sockets, siphoning data and arching backward into dense peripheral machinery. A strong CRT monitor glow bathes the metallic surfaces in cyan and electric blue light, while faint scanlines trace the polished alloy. The shallow background dissolves into shadowed banks of consoles accented with soft red and amber status lights, emphasizing the solitary, mechanized visage."
},
"_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": 763024022618349,
"steps": 30
},
"_meta": {
"title": "KSampler"
}
},
"28": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 768,
"width": 1344
},
"_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": "Anima",
"images": [
"8",
0
]
},
"_meta": {
"title": "Save Image"
}
}
})
# 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("46"):
output.to_file(output.name)