# 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({
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 4,
"denoise": 1,
"latent_image": [
"13",
0
],
"model": [
"11",
0
],
"negative": [
"25:7",
0
],
"positive": [
"26:7",
0
],
"sampler_name": "res_multistep",
"scheduler": "simple",
"seed": 942500763821827,
"steps": 30
},
"_meta": {
"title": "KSampler"
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "NetaYumev35_pretrained_all_in_one.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"4",
2
]
},
"_meta": {
"title": "VAE Decode"
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "NetaYume_Lumina_3.5",
"images": [
"8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"11": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"4",
0
],
"sampling": "flow",
"shift": 4
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"13": {
"class_type": "EmptySD3LatentImage",
"inputs": {
"batch_size": 1,
"height": 768,
"width": 1344
},
"_meta": {
"title": "EmptySD3LatentImage"
}
},
"25:22": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": "",
"string_a": [
"25:23",
0
],
"string_b": [
"25:24",
0
]
},
"_meta": {
"title": "Concatenate Text"
}
},
"25:23": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "You are an assistant designed to generate low-quality images based on textual prompts <Prompt Start> "
},
"_meta": {
"title": "System prompt"
}
},
"25:24": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "blurry, worst quality, low quality, jpeg artifacts, signature, watermark, username, error, deformed hands, bad anatomy, extra limbs, poorly drawn hands, poorly drawn face, mutation, deformed, extra eyes, extra arms, extra legs, malformed limbs, fused fingers, too many fingers, long neck, cross-eyed, bad proportions, missing arms, missing legs, extra digit, fewer digits, cropped"
},
"_meta": {
"title": "System prompt"
}
},
"25:7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": [
"25:22",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"26:22": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": "",
"string_a": [
"26:23",
0
],
"string_b": [
"26:24",
0
]
},
"_meta": {
"title": "Concatenate Text"
}
},
"26:23": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "You are an assistant designed to generate high quality anime images based on textual prompts. <Prompt Start> "
},
"_meta": {
"title": "System prompt"
}
},
"26:24": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "A richly detailed anime illustration depicts a slender young East Asian herbalist standing atop a sun-drenched coastal terrace. Her long, flowing raven hair is loosely braided with delicate jade pins and fragrant jasmine blossoms. She wears layered, billowing silk robes of pale lavender, saffron yellow, and mint green, embroidered with intricate golden threadwork along the sleeves. In one hand, she cradles an ornate brass astrolabe reflecting warm sunlight, while a woven bamboo basket rests beside her feet. Behind her, weathered ivory marble colonnades are entwined with vibrant violet wisteria and creeping ivy. Bathed in a radiant palette of turquoise ocean waters, peach-tinged clouds, and warm golden hour light, drifting petals dance across an expansive vista of distant mist-shrouded islands and sparkling sea foam."
},
"_meta": {
"title": "Prompt"
}
},
"26:7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": [
"26:22",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Positive 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("9"):
output.to_file(output.name)