# 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({
"25": {
"class_type": "ByteDanceSeedreamNode",
"inputs": {
"fail_on_partial": True,
"height": 2048,
"image": [
"31",
0
],
"max_images": 1,
"model": "seedream 5.0 lite",
"prompt": "Refer to the second image and repaint the first image entirely in its style: a traditional Japanese woodblock print with flat areas of colour, bold carved black outlines, stylised scalloped clouds and water, and the visible grain of washi paper and the printing block. Keep the content and layout of the first image: the motorcyclist seen from behind on a red-clay trail, her braid and helmet, the scrambler motorcycle, the lichen-covered tundra, the braided river and the snow-dusted volcanic ridges under heavy storm clouds. Use the second image's palette of indigo, teal, chalk white, cinnabar red and warm cream. No lettering, seals or signatures.",
"seed": 1372846604,
"sequential_image_generation": "disabled",
"size_preset": "2560x1440 (16:9)",
"watermark": False,
"width": 2048
},
"_meta": {
"title": "ByteDance Seedream 4.5 & 5.0"
}
},
"26": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Seedream5.0_lite",
"images": [
"25",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"29": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"31": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"29",
0
],
"images.image1": [
"32",
0
]
},
"_meta": {
"title": "Batch Images"
}
},
"32": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_2_FILENAME"
},
"_meta": {
"title": "Load Image"
}
}
})
workflow.set_input("29", "image", client.assets.from_url("https://comfy.org/catalog-media/f4a7ceb2-1b08-44e2-8fee-b96e406e7457/688aea2a-9e9b-4e45-a5f6-227eddefd721"))
workflow.set_input("32", "image", client.assets.from_url("https://comfy.org/catalog-media/b283be8d-b8c9-4c29-9828-d119a0640e6f/bf375f93-41fb-46ee-98d1-6f3661e1673f"))
# 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("26"):
output.to_file(output.name)