# 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": "ByteDanceSeedreamNode",
"inputs": {
"fail_on_partial": True,
"height": 2048,
"image": [
"11",
0
],
"max_images": 1,
"model": "seedream-4-0-250828",
"prompt": "Keep the amber glass bottle with its dark metal cap, the black faceted stone and the split fig exactly as they are, with the same shapes and the same arrangement, and move the whole still life outdoors onto a flat, moss-covered river stone at first light. Shallow clear water ripples around the base of the stone, and a few drops bead on the glass. Soft mist hangs over the stream behind, where out-of-focus ferns and birch trunks glow pale green and gold. Low, warm sunrise light comes in from the left, throwing long soft shadows to the right and catching a bright glint along the bottle's edges. Replace the dark backdrop entirely. Photorealistic product photography with crisp detail on the glass and the fig's seeds, natural colours, and no text or labels.",
"seed": 76371209,
"sequential_image_generation": "disabled",
"size_preset": "2560x1440 (16:9)",
"watermark": False,
"width": 2048
},
"_meta": {
"title": "ByteDance Seedream 4.5 & 5.0"
}
},
"11": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"12": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Seedream-4",
"images": [
"1",
0
]
},
"_meta": {
"title": "Save Image"
}
}
})
workflow.set_input("11", "image", client.assets.from_url("https://comfy.org/catalog-media/4546cf86-b1ab-4fda-9a4b-e597057a7ef0/be694a6f-cb0b-4064-afa4-ef9e5ca823be"))
# 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("12"):
output.to_file(output.name)