# 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({
"4": {
"class_type": "LoadImage",
"inputs": {
"button": {
"clicked": False,
"computedDisabled": False,
"computedHeight": 24,
"label": "choose file to upload",
"last_y": 70,
"name": "upload",
"options": {
"canvasOnly": True,
"serialize": False
},
"type": "button",
"y": 70
},
"image": "de8196b2e4887c7e987d9940dbd4c886bbdab2a04bea3187590426e237408fac.png"
},
"_meta": {
"title": "Load Logo Image"
}
},
"7": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "1:1",
"images": [
"21:27",
0
],
"model": "gemini-3-pro-image-preview",
"prompt": "Apply the texture and background from image 2 into the logo from image 1. The logotype is in a 3d setting, match the lighting from the matcap. Use the elements from image 3, duplicate and apply them in multiple sizes and positions, scattered throughout the 3d environment creating a sense of depth and playful composition",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 495849069868986,
"system_prompt": "You are an expert image-generation engine. You must ALWAYS produce an image.\nInterpret all user input—regardless of format, intent, or abstraction—as literal visual directives for image composition.\nIf a prompt is conversational or lacks specific visual details, you must creatively invent a concrete visual scenario that depicts the concept.\nPrioritize generating the visual representation above any text, formatting, or conversational requests."
},
"_meta": {
"title": "Nano Banana Pro (Google Gemini Image)"
}
},
"11": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"24",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"13": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"7",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"17": {
"class_type": "LoadImage",
"inputs": {
"button": {
"clicked": False,
"computedDisabled": False,
"computedHeight": 24,
"label": "choose file to upload",
"last_y": 70,
"name": "upload",
"options": {
"canvasOnly": True,
"serialize": False
},
"type": "button",
"y": 70
},
"image": "de8196b2e4887c7e987d9940dbd4c886bbdab2a04bea3187590426e237408fac.png"
},
"_meta": {
"title": "Load Texture Image"
}
},
"18": {
"class_type": "LoadImage",
"inputs": {
"button": {
"clicked": False,
"computedDisabled": False,
"computedHeight": 24,
"label": "choose file to upload",
"last_y": 70,
"name": "upload",
"options": {
"canvasOnly": True,
"serialize": False
},
"type": "button",
"y": 70
},
"image": "de8196b2e4887c7e987d9940dbd4c886bbdab2a04bea3187590426e237408fac.png"
},
"_meta": {
"title": "Load Elements Image"
}
},
"24": {
"class_type": "ByteDanceImageToVideoNode",
"inputs": {
"aspect_ratio": "adaptive",
"camera_fixed": True,
"duration": 5,
"generate_audio": False,
"image": [
"7",
0
],
"model": "seedance-1-0-pro-250528",
"prompt": "A floating logo wordmark playfully animates. The logo has a fluffy texture. The camera remains static, focusing on the elements in the scene animate individually and float making distinctly subtle but fun movements",
"resolution": "1080p",
"seed": 125213764,
"watermark": False
},
"_meta": {
"title": "ByteDance Image to Video"
}
},
"21:15": {
"class_type": "ResizeAndPadImage",
"inputs": {
"image": [
"17",
0
],
"interpolation": "area",
"padding_color": "white",
"target_height": [
"21:16",
1
],
"target_width": [
"21:16",
0
]
},
"_meta": {
"title": "Resize And Pad Image"
}
},
"21:16": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"4",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"21:20": {
"class_type": "ResizeAndPadImage",
"inputs": {
"image": [
"18",
0
],
"interpolation": "area",
"padding_color": "white",
"target_height": [
"21:16",
1
],
"target_width": [
"21:16",
0
]
},
"_meta": {
"title": "Resize And Pad Image"
}
},
"21:27": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"4",
0
],
"images.image1": [
"21:15",
0
],
"images.image2": [
"21:20",
0
]
},
"_meta": {
"title": "Batch Images"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)