# 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({
"124": {
"class_type": "LoadImage",
"inputs": {
"image": "silver_hand.png"
},
"_meta": {
"title": "Load Image"
}
},
"136": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the shadows to match the following lighting style: dual rim backlight, no front key, twin hard lights from behind left and right, subject silhouetted at center, glowing edge separation on both sides, dramatic dark fill",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 194380522768098,
"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)"
}
},
"138": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"136",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"150": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Hard top-down overhead key, harsh light directly above, deep under-eye and jaw shadows, pronounced brow ridge highlight, strong nose shadow pointing straight down, theatrical and sculpted",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 31312554729959,
"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)"
}
},
"152": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"150",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"156": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Split lighting, hard side key at 90°, one half face fully lit, other half near-black, sharp nose shadow line, minimal fill.",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 337125210981716,
"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)"
}
},
"158": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"156",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"168": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Rembrandt, side key slightly above, deep falloff, subtle rim separation.",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 95962613515780,
"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)"
}
},
"170": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"168",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"180": {
"class_type": "GeminiImage2Node",
"inputs": {
"aspect_ratio": "auto",
"images": [
"124",
0
],
"model": "Nano Banana 2 (Gemini 3.1 Flash Image)",
"prompt": "Maintain the identity of input image 1, modify the scene lighting and shadows to match the following lighting style: Motivated practical, off-axis kicker mimicking an environmental source, strong directional spill, naturalistic shadow logic, atmospheric fill.",
"resolution": "1K",
"response_modalities": "IMAGE+TEXT",
"seed": 16095681705317,
"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)"
}
},
"181": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-nb_2",
"images": [
"180",
0
]
},
"_meta": {
"title": "Save Image"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)