# 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({
"46": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Anima",
"images": [
"60:8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"60:11": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"60:45",
0
],
"text": "An anime illustration from an expansive, distant low-angle perspective. A slender East Asian teenage girl with long braided midnight-black hair stands poised atop the edge of a crumbling skyscraper roof, overlooking an immense neon metropolis at midnight. She wears an oversized iridescent violet windbreaker with glowing amber trims, dark cargo shorts, and fingerless gloves. One hand rests on her hip while she looks out toward the horizon with a calm, resolute smirk. The sprawling urban vista extends outward under a hazy night sky, illuminated by vibrant crimson neon signs, cyan reflections across glass facades, and deep indigo shadows. Crisp cel-shaded character styling combines with sharp ink line art and a lush, richly textured painterly background."
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"60:12": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"60:45",
0
],
"text": "worst quality, low quality, score_1, score_2, score_3, blurry, jpeg artifacts, sepia"
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"60:15": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"60:19": {
"class_type": "KSampler",
"inputs": {
"cfg": 4,
"denoise": 1,
"latent_image": [
"60:28",
0
],
"model": [
"60:44",
0
],
"negative": [
"60:12",
0
],
"positive": [
"60:11",
0
],
"sampler_name": "er_sde",
"scheduler": "simple",
"seed": 875817230929465,
"steps": 30
},
"_meta": {
"title": "KSampler"
}
},
"60:28": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 768,
"width": 1344
},
"_meta": {
"title": "Empty Latent Image"
}
},
"60:44": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "anima-base-v1.0.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"60:45": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_06b_base.safetensors",
"device": "default",
"type": "stable_diffusion"
},
"_meta": {
"title": "Load CLIP"
}
},
"60:8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"60:19",
0
],
"vae": [
"60:15",
0
]
},
"_meta": {
"title": "VAE Decode"
}
}
})
# 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)