# 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": "Krea3ImageNode",
"inputs": {
"model": "Krea 3",
"model.aspect_ratio": "auto",
"model.precise_edit": False,
"model.prompt": "Extreme low-angle shot of a female athlete stretching under an overpass, emphasizing a prominent light-colored running shoe with orange accents in the foreground. She wears a dark jacket, cap, sunglasses, and light blue socks. Dramatic mixed lighting contrasts dark bridge shadows with bright background daylight. Captured with a wide-angle lens for dynamic forced perspective. Absolutely no text, no typography, no letters, no words, no numbers, no logos, no watermark, no captions, pure imagery only.",
"model.resolution": "1K",
"model.seed": 1356972165,
"model.thinking_mode": "fast"
},
"_meta": {
"title": "Krea 3 Image"
}
},
"7": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "api_krea3_t2i",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"1",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
}
})
# 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("7"):
output.to_file(output.name)