Extensions/ComfyUI-Nerapi
ComfyUI Extension

ComfyUI-Nerapi

ComfyUI custom nodes for Nano-Banana (nano-banana-pro / nano-banana-2) and GPT-Image-2 — text-to-image and image-to-image via the Nerapi API gateway.

By Guguniaoer·Created about a month ago·Updated about a month ago· 0
Guguniaoer/ComfyUI-Nerapi
Nodes2
On cloudLocal install
CategoryNano-Banana / GPT-Image
Stars0
Updatedabout a month ago
Readme

ComfyUI-Nerapi

在 ComfyUI 里用 Nano-Banana(nano-banana-pro / nano-banana-2)和 GPT-Image-2 生图与图生图。两个独立节点,支持文生图、最多 8 张参考图的图生图。

功能特点

  • 两个模型节点Nano-Banana(含 pro / 2)和 GPT-Image-2
  • 文生图 + 图生图:最多 8 张参考图输入
  • 比例可选1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 3:2 / 2:3 / 5:4 / 4:5 / 21:9(nano-banana-2 额外支持 1:4 / 4:1 / 1:8 / 8:1,选 pro 时会自动隐藏)
  • 清晰度:Nano-Banana 支持 1K / 2K / 4K;GPT-Image-2 固定 1K
  • 界面中文:所有参数标签中文显示

如何获取 API Key(重要)

本节点通过 nerapi.com 的 API 网关调用模型,所以你需要一个 nerapi 的 API Key:

  1. 打开 https://nerapi.com注册并登录
  2. 充值,确保账户余额大于 0——生图、以及参考图上传(走图床)都会消耗余额,余额为 0 会失败。
  3. 进入后台的 API 令牌 / API Keys / 密钥管理 页面,新建一个密钥并复制(格式类似 sk-xxxxxxxx)。
  4. 回到 ComfyUI,把这个密钥粘贴到节点的 密钥 输入框里。

提示:后台里菜单的具体名字可能叫「令牌」「API Key」或「密钥」,登录后找带 key/token 字样的那一项即可。

安装

把整个文件夹放到 ComfyUI 的 custom_nodes/ 目录,安装依赖后重启:

git clone https://github.com/Guguniaoer/ComfyUI-Nerapi.git
cd ComfyUI/custom_nodes/ComfyUI-Nerapi
pip install -r requirements.txt

用整合包(如秋叶)的话,pip 要用整合包自带的 Python,例如 python_embeded\python.exe -m pip install -r requirements.txt

使用

节点在 Nano-Banana / GPT-Image 分类下,搜 Nano-BananaGPT-Image 即可添加。输出「图像」直接接 Preview / Save Image。

Nano-Banana

  • 密钥:你的 nerapi API Key(见上文)
  • 提示词:图片描述
  • 模型nano-banana-pro / nano-banana-2
  • 比例:如 1:116:91:4/4:1/1:8/8:1 仅 nano-banana-2 可用,选 pro 时自动隐藏)
  • 清晰度1K / 2K / 4K
  • 可选:图片1~图片8(参考图,图生图用)、接口地址、轮询间隔、超时秒数 <img width="2876" height="1712" alt="1" src="https://github.com/user-attachments/assets/8e1041a6-8ee8-4353-980d-d7212ab5e7ce" />
<img width="2688" height="1779" alt="2" src="https://github.com/user-attachments/assets/f9dae481-2963-4621-8466-b8b357dcbf29" />

GPT-Image-2

  • 密钥 / 提示词:同上
  • 比例:默认 1:1(固定 1K 分辨率)
  • 可选:图片1~图片8、接口地址、轮询间隔、超时秒数 <img width="2870" height="1662" alt="3" src="https://github.com/user-attachments/assets/cbc23ed6-6d2c-49c4-9f63-275e477b3ef8" />

参考图(图生图)如何工作

模型接口的参考图只接受公网图片 URL,不接受 base64。所以你接了「图片」输入时,节点会自动:

  1. POST /v1/api/upload-token 拿一次性图床凭证
  2. 把图片直传到返回的地址
  3. 用返回的 downloadUrl 提交生图

⚠️ 图床上传需账户余额 > 0;图床链接约 6 小时有效、文件 1 天后清理,仅供「上传后立即生图」。

快速测试(不进 ComfyUI)

test_api.py 先验证 key 和接口通不通:

pip install requests
python test_api.py --key sk-你的key --model gpt-image-2 --prompt "一只戴墨镜的柴犬"
python test_api.py --key sk-你的key --model nano-banana-pro --size 2K --ratio 16:9

成功会把图存成 nerapi_test_output.png。401=key 错误,提示 balance=余额不足,400=模型名/参数不对。

备注

各模型支持的比例 / 清晰度组合以 nerapi 后台为准,遇到不被接受的组合请换文档中的取值。

License

MIT