ComfyUI Extension: ComfyUI-Nanobanana
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
Gemini native generateContent custom nodes for ComfyUI with Nano Banana, Nano Banana 2, and Nano Banana Pro, supporting both Google direct access and Gemini-compatible native relay endpoints.
Looking for a different extension?
Custom Nodes (3)
README
ComfyUI-Nanobanana
ComfyUI-Nanobanana 是一个直接封装 Gemini 原生 generateContent 图像接口的 ComfyUI 自定义节点包,支持:
- Google 官方 Gemini 原生直连
- 保留 Gemini 原生路径形态的中转站
- ComfyUI
IMAGE批量输入作为参考图 - 标准
IMAGE输出,可直接接PreviewImage/SaveImage text与response_json调试输出
本项目当前只兼容 Gemini 原生格式:
POST /v1beta/models/{model}:generateContent
本项目当前不兼容:
/v1/chat/completions- OpenAI Chat 兼容格式
- grounding、多轮会话、thought signature 续传
节点列表
ComfyUI-Nanobanana Nano BananaComfyUI-Nanobanana Nano Banana 2ComfyUI-Nanobanana Nano Banana Pro
ComfyUI-Nanobanana Client 已移除。连接信息现在统一从后端配置文件读取,不再出现在前端 workflow 中。
模型映射
Nano Banana->gemini-2.5-flash-imageNano Banana 2->gemini-3.1-flash-image-previewNano Banana Pro->gemini-3-pro-image-preview
安装
cd ComfyUI/custom_nodes
git clone https://github.com/magicwang1111/ComfyUI-Nanobanana.git
cd ComfyUI-Nanobanana
python -m pip install -r requirements.txt
配置方式
首选方式是在仓库根目录创建 config.local.json。可以先复制 config.example.json 再填写:
{
"api_key": "",
"request_timeout": 60,
"base_url": "https://generativelanguage.googleapis.com",
"auth_mode": "x-goog-api-key",
"send_seed": true
}
说明:
config.local.json是本地私有文件,已经加入.gitignoreconfig.example.json只是示例,不会被程序当作真实配置读取config.ini仍保留兼容回退能力,但不再是推荐配置方式
配置优先级
api_key
config.local.json中的api_key- 环境变量
NANOBANANA_API_KEY - 环境变量
GEMINI_API_KEY config.ini中的NANOBANANA_API_KEYconfig.ini中的GEMINI_API_KEY
base_url
config.local.json中的base_url- 环境变量
NANOBANANA_BASE_URL config.ini中的NANOBANANA_BASE_URL- 默认值
https://generativelanguage.googleapis.com
auth_mode
config.local.json中的auth_mode- 环境变量
NANOBANANA_AUTH_MODE config.ini中的NANOBANANA_AUTH_MODE- 默认值
x-goog-api-key
send_seed
config.local.json中的send_seed- 环境变量
NANOBANANA_SEND_SEED config.ini中的NANOBANANA_SEND_SEED- 默认值
true
request_timeout
config.local.json中的request_timeout- 默认值
60
auth_mode
x-goog-api-key适用于 Google 官方 Gemini 原生接口bearer适用于要求Authorization: Bearer <token>的 Gemini 原生中转站
send_seed
true会透传generationConfig.seedfalse不发送generationConfig.seed
如果某个中转站返回 Invalid value at 'generation_config.seed',请把 send_seed 关闭。
生成节点参数
三个生成节点都会保留原有本地能力校验,并新增一个用于中转站模型别名的参数:
model_override
规则如下:
- 留空时,继续使用节点内置官方模型名
- 填值时,请求会发往覆盖后的模型名
- 本地参数校验仍按当前节点原始模型规格执行
Nano Banana
promptseedimages可选aspect_ratioresponse_modesystem_promptmodel_override
Nano Banana 2
promptseedimages可选aspect_ratioresponse_modesystem_promptmodel_overrideresolutionthinking_levelinclude_thoughts
Nano Banana Pro
promptseedimages可选aspect_ratioresponse_modesystem_promptmodel_overrideresolutionthinking_level
中转站配置示例
Google 官方直连
{
"api_key": "your_token_here",
"request_timeout": 60,
"base_url": "https://generativelanguage.googleapis.com",
"auth_mode": "x-goog-api-key",
"send_seed": true
}
Gemini 原生中转站
{
"api_key": "your_token_here",
"request_timeout": 60,
"base_url": "https://your-relay.example.com",
"auth_mode": "bearer",
"send_seed": true
}
如中转站模型名与官方不同,可在生成节点里填写 model_override。如果中转站不接受 generationConfig.seed,把 send_seed 改成 false 即可。
AIHubMix
{
"api_key": "your_token_here",
"request_timeout": 60,
"base_url": "https://aihubmix.com/gemini",
"auth_mode": "x-goog-api-key",
"send_seed": true
}
AIHubMix 的站点兼容规则已经在后端处理:
Nano Banana 2保持原样Nano Banana Pro会自动移除显式的thinkingLevel
行为说明
response_mode默认是IMAGE+TEXTsend_seed=true时才会透传generationConfig.seedaspect_ratio=auto时不会显式写入imageConfig.aspectRatiosystem_prompt默认是一段“始终产图”的图像生成提示词response_json会保留原始返回结构,但会把 base64 图片数据替换为占位文本- 响应解析兼容
inlineData/mimeType与inline_data/mime_type Nano Banana 2若没有返回 thought 图,thought_image会输出占位黑图
示例工作流
示例 workflow 位于 examples/README.md:
01_comfyui_nanobanana_nano_banana.json02_comfyui_nanobanana_nano_banana_2.json03_comfyui_nanobanana_nano_banana_pro.json
这些示例已经不再依赖 Client 节点,导入前只需要先准备好 config.local.json。
测试
python -m unittest discover -s tests -v
已知限制
- 只支持单次请求,不保存会话与 thought signatures
- 不兼容
/v1/chat/completions - 不做 grounding,因此不会返回来源链接或搜索元数据
- 输入图像数量仍做保守限制:
Nano Banana最多 3 张Nano Banana 2 / Pro最多 14 张
参考
- Google AI for Developers: https://ai.google.dev/gemini-api/docs/image-generation
- Gemini 3 guide: https://ai.google.dev/gemini-api/docs/gemini-3
- Pricing: https://ai.google.dev/gemini-api/docs/pricing
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.