# 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({
"11": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"30": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "nano_banana_pro",
"images": [
"38",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"37": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "nano_banana_pro",
"images": [
"39",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"38": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "16:9",
"images": [
"11",
0
],
"model": "gemini-3-pro-image-preview",
"prompt": "Create an orthographic blueprint that describes this building in plan, elevation and section.",
"resolution": "1K",
"response_modalities": "IMAGE",
"seed": 42,
"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)"
}
},
"39": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "16:9",
"images": [
"40",
0
],
"model": "gemini-3-pro-image-preview",
"prompt": "A miniature architectural scale model of a black timber two-storey house with a steep gabled zinc roof, a deep veranda on slender posts and tall glass walls, carefully crafted from charcoal-stained basswood and frosted acrylic with clean edges and fine textures. The model sits on an architect's wooden work desk surrounded by design tools: a cutting mat, steel rulers, pencils, foam board scraps and a warm desk lamp. Behind the desk, pinned to the wall, is the blueprint shown in the reference image, its plan, elevation and section lines clearly visible. Natural side daylight, realistic professional photography, shallow depth of field, high detail.",
"resolution": "1K",
"response_modalities": "IMAGE",
"seed": 42,
"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)"
}
},
"40": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"11",
0
],
"images.image1": [
"38",
0
]
},
"_meta": {
"title": "Batch Images"
}
}
})
workflow.set_input("11", "image", client.assets.from_url("https://comfy.org/catalog-media/862cd693-741c-44c4-a191-55eba457b918/9e0b0c64-e996-4d4f-bcbf-98ad1c858277"))
# 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("37"):
output.to_file(output.name)
for output in job.get_outputs("30"):
output.to_file(output.name)