# 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({
"1": {
"class_type": "Krea2ImageNode",
"inputs": {
"model": "Krea 2 Large",
"model.aspect_ratio": "16:9",
"model.creativity": "medium",
"model.moodboard_id": "7947e7b8-750e-4dbd-877a-d554d86f85d1",
"model.moodboard_strength": 0.35,
"model.resolution": "1K",
"prompt": "An extreme low-angle distant shot captured with a 24mm ultra-wide lens across an expansive cracked white salt flat stretching endlessly toward distant jagged obsidian mountains. In the vast open terrain, a lone nomadic traveler draped in coarse, sun-bleached burlap stands beside a weathered cedar-wood pack handcart with oxidized copper rims. Blinding amber golden-hour sunlight cuts across the arid landscape from the low horizon, creating fierce high-contrast rim lighting on the traveler’s silhouette and throwing elongated violet shadows across the hexagonal crystalline ground. A single glowing crimson lantern hangs from the wooden cart's beam, puncturing the warm monochromatic desert glow with a sharp point of saturated color. Micro-textures of chalky mineral dust, fibrous dry hemp ropes, and fractured terrain define the sweeping panoramic expanse.",
"seed": 25736235
},
"_meta": {
"title": "Krea 2 Image"
}
},
"2": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"1",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"44": {
"class_type": "Krea2ImageNode",
"inputs": {
"model": "Krea 2 Large",
"model.aspect_ratio": "16:9",
"model.creativity": "medium",
"model.moodboard_id": "176345d7-b1e0-4b44-bf06-ce4d7b8b8062",
"model.moodboard_strength": 0.35,
"model.resolution": "1K",
"prompt": "An extreme low-angle distant shot captured with a 24mm ultra-wide lens across an expansive cracked white salt flat stretching endlessly toward distant jagged obsidian mountains. In the vast open terrain, a lone nomadic traveler draped in coarse, sun-bleached burlap stands beside a weathered cedar-wood pack handcart with oxidized copper rims. Blinding amber golden-hour sunlight cuts across the arid landscape from the low horizon, creating fierce high-contrast rim lighting on the traveler’s silhouette and throwing elongated violet shadows across the hexagonal crystalline ground. A single glowing crimson lantern hangs from the wooden cart's beam, puncturing the warm monochromatic desert glow with a sharp point of saturated color. Micro-textures of chalky mineral dust, fibrous dry hemp ropes, and fractured terrain define the sweeping panoramic expanse.",
"seed": 1039717954
},
"_meta": {
"title": "Krea 2 Image"
}
},
"45": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"44",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"50": {
"class_type": "Krea2ImageNode",
"inputs": {
"model": "Krea 2 Large",
"model.aspect_ratio": "16:9",
"model.creativity": "medium",
"model.moodboard_id": "aa2178a3-36f1-47f6-8d2a-c3578d5329af",
"model.moodboard_strength": 0.35,
"model.resolution": "1K",
"prompt": "An extreme low-angle distant shot captured with a 24mm ultra-wide lens across an expansive cracked white salt flat stretching endlessly toward distant jagged obsidian mountains. In the vast open terrain, a lone nomadic traveler draped in coarse, sun-bleached burlap stands beside a weathered cedar-wood pack handcart with oxidized copper rims. Blinding amber golden-hour sunlight cuts across the arid landscape from the low horizon, creating fierce high-contrast rim lighting on the traveler’s silhouette and throwing elongated violet shadows across the hexagonal crystalline ground. A single glowing crimson lantern hangs from the wooden cart's beam, puncturing the warm monochromatic desert glow with a sharp point of saturated color. Micro-textures of chalky mineral dust, fibrous dry hemp ropes, and fractured terrain define the sweeping panoramic expanse.",
"seed": 1121547250
},
"_meta": {
"title": "Krea 2 Image"
}
},
"51": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"50",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"59": {
"class_type": "Krea2ImageNode",
"inputs": {
"model": "Krea 2 Large",
"model.aspect_ratio": "16:9",
"model.creativity": "medium",
"model.moodboard_id": "b6edb7f2-1f75-4dd6-8774-09c7e4f415cc",
"model.moodboard_strength": 0.35,
"model.resolution": "1K",
"prompt": "An extreme low-angle distant shot captured with a 24mm ultra-wide lens across an expansive cracked white salt flat stretching endlessly toward distant jagged obsidian mountains. In the vast open terrain, a lone nomadic traveler draped in coarse, sun-bleached burlap stands beside a weathered cedar-wood pack handcart with oxidized copper rims. Blinding amber golden-hour sunlight cuts across the arid landscape from the low horizon, creating fierce high-contrast rim lighting on the traveler’s silhouette and throwing elongated violet shadows across the hexagonal crystalline ground. A single glowing crimson lantern hangs from the wooden cart's beam, puncturing the warm monochromatic desert glow with a sharp point of saturated color. Micro-textures of chalky mineral dust, fibrous dry hemp ropes, and fractured terrain define the sweeping panoramic expanse.",
"seed": 1686490302
},
"_meta": {
"title": "Krea 2 Image"
}
},
"60": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"59",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"65": {
"class_type": "Krea2ImageNode",
"inputs": {
"model": "Krea 2 Large",
"model.aspect_ratio": "16:9",
"model.creativity": "medium",
"model.moodboard_id": "dba7dbec-86cc-4ec1-8195-5a486ce15939",
"model.moodboard_strength": 0.35,
"model.resolution": "1K",
"prompt": "An extreme low-angle distant shot captured with a 24mm ultra-wide lens across an expansive cracked white salt flat stretching endlessly toward distant jagged obsidian mountains. In the vast open terrain, a lone nomadic traveler draped in coarse, sun-bleached burlap stands beside a weathered cedar-wood pack handcart with oxidized copper rims. Blinding amber golden-hour sunlight cuts across the arid landscape from the low horizon, creating fierce high-contrast rim lighting on the traveler’s silhouette and throwing elongated violet shadows across the hexagonal crystalline ground. A single glowing crimson lantern hangs from the wooden cart's beam, puncturing the warm monochromatic desert glow with a sharp point of saturated color. Micro-textures of chalky mineral dust, fibrous dry hemp ropes, and fractured terrain define the sweeping panoramic expanse.",
"seed": 1564896885
},
"_meta": {
"title": "Krea 2 Image"
}
},
"66": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"65",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"71": {
"class_type": "Krea2ImageNode",
"inputs": {
"model": "Krea 2 Large",
"model.aspect_ratio": "16:9",
"model.creativity": "medium",
"model.moodboard_id": "3b1eac6e-fe46-49dc-8fd7-3a2bc3c2f445",
"model.moodboard_strength": 0.35,
"model.resolution": "1K",
"prompt": "An extreme low-angle distant shot captured with a 24mm ultra-wide lens across an expansive cracked white salt flat stretching endlessly toward distant jagged obsidian mountains. In the vast open terrain, a lone nomadic traveler draped in coarse, sun-bleached burlap stands beside a weathered cedar-wood pack handcart with oxidized copper rims. Blinding amber golden-hour sunlight cuts across the arid landscape from the low horizon, creating fierce high-contrast rim lighting on the traveler’s silhouette and throwing elongated violet shadows across the hexagonal crystalline ground. A single glowing crimson lantern hangs from the wooden cart's beam, puncturing the warm monochromatic desert glow with a sharp point of saturated color. Micro-textures of chalky mineral dust, fibrous dry hemp ropes, and fractured terrain define the sweeping panoramic expanse.",
"seed": 717056163
},
"_meta": {
"title": "Krea 2 Image"
}
},
"72": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"71",
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("2"):
output.to_file(output.name)
for output in job.get_outputs("45"):
output.to_file(output.name)
for output in job.get_outputs("51"):
output.to_file(output.name)
for output in job.get_outputs("60"):
output.to_file(output.name)
for output in job.get_outputs("66"):
output.to_file(output.name)
for output in job.get_outputs("72"):
output.to_file(output.name)