# 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({
"14": {
"class_type": "ByteDanceSeedreamNodeV3",
"inputs": {
"model": "seedream 5.0 flash",
"model.height": 2048,
"model.images.image_1": [
"16",
0
],
"model.seed": 623508325,
"model.size_preset": "(1K) 1024x1024 (1:1)",
"model.watermark": False,
"model.width": 2048,
"prompt": "Photorealistic commercial product photography, a complete wine brand collection display derived from the reference image. Central hero is the original wine bottle with its purple label and two-women flat grain illustration. Surrounding products include a rigid wine gift box, canvas tote bag, wine glass, corkscrew, wooden cork, small grape cluster, branded paper card and fabric pouch. All items are printed or decorated with the same brand visual identity from reference: two women characters, geometric flowers, lavender purple, royal blue, pink, orange, grainy flat graphic style. Arranged on a light wooden table with soft studio lighting, elegant lifestyle mockup, shallow depth of field, realistic glass, paper and fabric texture, premium wine brand styling, clean background, high detail.\n"
},
"_meta": {
"title": "ByteDance Seedream 4.5, 5.0 & 5.5"
}
},
"15": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "Seedream5.0_flash",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"14",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
},
"16": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
}
})
workflow.set_input("16", "image", client.assets.from_url("https://comfy.org/catalog-media/ef5427df-f14c-4ca0-a020-911d53007337/a22a56d7-ac1a-481f-9cad-3c219e2902eb"))
# 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("15"):
output.to_file(output.name)