# 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({
"376": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"391": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "api_openai_gpt_image_26_sunburst_image_edit",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"392",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
},
"392": {
"class_type": "OpenAIGPTImageNodeV2",
"inputs": {
"model": "gpt-image-2.6-sunburst",
"model.background": "auto",
"model.complexity": "high",
"model.custom_height": 1024,
"model.custom_width": 1024,
"model.images.image_1": [
"376",
0
],
"model.quality": "low",
"model.size": "auto",
"n": 1,
"prompt": "Edit this color photo into a photoreal Magritte-like surreal photograph. CRITICAL continuity locks: keep the Volkswagen Type 2 bus in the EXACT same position, scale, orientation, three-quarter angle, hover height, and circular-hole piercing relationship as the reference — do NOT move, rotate, enlarge, shrink, or restage the vehicle. Keep the same camera height and framing. Photoreal fine-art photography only — NO illustration, NO comic, NO CGI cartoon look.\n\nReplace the concrete walls with a monumental vertical WALL MADE OF REAL CLOUDS: dense sculpted cumulus that still reads as a flat architectural plane meeting at a right angle, with a PERFECT circular aperture cut through the cloud-mass — the bus must protrude through that cloud-hole exactly as it did through concrete (front hanging in open air, rear still inside the cloud wall). The courtyard floor becomes a soft continuous cloud deck / mist floor beneath the hovering bus. Beyond the cloud walls: authentic open sky and distant real atmospheric clouds under soft overcast daylight.\n\nRelight the cream VW for open-sky conditions: cool skylight fill, soft diffuse shadows, faint sky-color bounce on body panels, natural specular on chrome and glass matching the cloudy sky — no studio look.\n\nIntegrate LARGE environmental typography formed in the cloud wall itself or as soft shadow-lettering across the cloud face (partially occluded by the bus), readable exact text: \"GPT IMAGE 2.6\" and \"SUNBURST\". No other slogans, no people.\n\nThe vertical plane must literally be clouds the bus is stuck in — not a cliff above clouds.",
"seed": 553435342
},
"_meta": {
"title": "OpenAI GPT Image"
}
}
})
workflow.set_input("376", "image", client.assets.from_url("https://comfy.org/catalog-media/911dfbb2-75d9-4a7b-8fb4-1710121ba7b1/eb55d42c-e165-4e79-97fd-e714fb8d6982"))
# 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("391"):
output.to_file(output.name)