# 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({
"10": {
"class_type": "OpenAIGPTImage1",
"inputs": {
"background": "opaque",
"custom_height": 1024,
"custom_width": 1024,
"model": "gpt-image-1.5",
"n": 1,
"prompt": "On a sunny day, a delicate Eiffel Tower made entirely of felt and wool, with rich details, highly realistic structure but with a cute, slightly exaggerated cartoonish style. The scene is filled with felt-textured small cars, pedestrians, people riding bicycles, and little dogs. In the background, there is a blue sky with soft clouds and a blurred, gentle Paris city skyline. The overall tone is bright, warm, and soft. The atmosphere is full of childlike fun and handcrafted charm, with every object resembling soft plush toys. The viewpoint is slightly low-angle, making the Eiffel Tower appear tall yet friendly.\n",
"quality": "high",
"seed": 667955921,
"size": "1024x1024"
},
"_meta": {
"title": "OpenAI GPT Image 2"
}
},
"14": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"10",
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)