Nodes/comfyui-gemini-apikey/Nano Banana Pro (API Key)
ComfyUI Node

Nano Banana Pro (API Key)

Nano Banana Pro in your graph, without the Comfy credit storefront

By mortyhuang·Created 6 months ago·Updated 6 months ago· 0
Nano Banana Pro (API Key)
  • images
  • files
  • IMAGE
  • STRING
prompt
modelgemini-3-pro-image-preview
seed42
aspect_ratioauto
resolution1K
response_modalitiesIMAGE+TEXT
system_promptYou are an expert image-generation engine. You must ALWAYS produce an image. Interpret all user input—regardless of format, intent, or abstraction—as literal visual directives for image composition. If a prompt is conversational or lacks specific visual details, you must creatively invent a concrete visual scenario that depicts the concept. Prioritize generating the visual representation above any text, formatting, or conversational requests.

Nano Banana Pro is Google's flagship image model - the one with 4K native output and the "thinking mode" everyone gushed about when it landed. Like every Nano Banana, it has no open weights, so the only way to use it is through an API. This node is that API call, wearing a clean ComfyUI face and paying for itself on your own Gemini key instead of through Comfy's Partner Node credits.

What it actually gives you

Two things the base model can't. First, native 4K output straight from the model - no upscaling step needed unless you want one. Second, the flagship model's quality, which is why this is the node people wire in front of an open video model: generate a reference-grade frame on Google's API, then animate it with Wan or LTX locally. It's the most popular closed-model-plus-open-motion pattern in the ecosystem, and this is the bring-your-own-key way to do the closed half.

How it works

Same trick as its sibling in this pack: a thin HTTP client that sends your prompt (plus any reference images, base64-encoded) to generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent, then decodes the returned image into a ComfyUI tensor. No local model, no VRAM, no weights - every call is metered and every result carries Google's invisible SynthID watermark. The honest version of that sentence: your prompt and images leave the machine, and Google's content filter is the only filter there is, since there's nothing local to patch.

The inputs that matter

  • model - this is the fun one. The dropdown defaults to gemini-3-pro-image-preview but also offers "Nano Banana 2 (Gemini 3.1 Flash Image)," so one node can call either the flagship or the cheaper, faster hybrid. Pick by budget and speed, not loyalty.
  • prompt - multiline, and the whole point. If you go IMAGE+TEXT you can even chat with the result.
  • seed - passed through to the API. Repeatable-ish, not pixel-deterministic; a closed cloud model is not a local sampler.
  • aspect_ratio - auto plus presets from 1:1 to 21:9.
  • resolution - 1K, 2K, 4K. Pro's 4K is where the per-image price climbs into the high end of Google's $0.039–0.24 range.
  • response_modalities - defaults to IMAGE+TEXT (the base-2 node defaults to IMAGE). Switch to IMAGE to skip the text entirely.

One honest gap: the Pro node here doesn't expose the thinking_level toggle its base-2 sibling has, even though thinking mode is Pro's marquee feature. You get the pro model as configured by Google - you just don't get a knob for it.

Optional inputs mirror the pack's other node: images (up to 14 via a Batch Images node, for multi-image editing), system_prompt to override the built-in "always produce an image" instruction, and files expecting a GEMINI_INPUT_FILES object - this pack ships no producer for that type, so it stays unplugged unless another pack provides one.

Outputs

IMAGE goes to a preview or Save Image node. STRING carries the model's text response - a caption of what it made, or its reply when you're doing IMAGE+TEXT.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/mortyhuang/comfyui-gemini-apikey

Restart (or grab "comfyui-gemini-apikey" from ComfyUI Manager). Then create ComfyUI/user/gemini_config.json:

{ "api_key": "YOUR_ACTUAL_KEY_HERE" }

The code also reads a GEMINI_API_KEY env var. Dependencies are just requests, torch, numpy, Pillow - nothing extra to download, no model files. Get the key from Google AI Studio.

Where people get burned

The "Gemini API Key missing" error means that config file isn't where the code expects it - double-check the path. Watch the meter: a session of 4K Pro images empties a free-tier budget embarrassingly fast, so budget resolution down to 1K/2K for drafts. And treat this pack the way you'd treat any small credential-holding API node - it's essentially unknown in the community, it phones home by design, and its ~300 lines of source are worth a skim before you trust it with a paid key. If that feels like too much, Comfy's official Partner Node gives you the same model behind more vetting, at the price of its credit system.

Categoryapi node/image/Gemini

Inputs (9)

NameTypeDefaultDescription
promptSTRINGText prompt describing the image.
modelCOMBOgemini-3-pro-image-preview2 options: gemini-3-pro-image-preview, Nano Banana 2 (Gemini 3.1 Flash Image)
seedINT420–2147483647
aspect_ratioCOMBOauto11 options: auto, 1:1, 2:3, 3:2, 3:4, 4:3, +5
resolutionCOMBO1K3 options: 1K, 2K, 4K
response_modalitiesCOMBOIMAGE+TEXT2 options: IMAGE+TEXT, IMAGE
imagesoptIMAGEOptional reference image(s). To include multiple images, use the Batch Images node (up to 14).
filesoptGEMINI_INPUT_FILESOptional file(s) from Gemini Input Files node.
system_promptoptSTRINGYou are an expert image-generation engine. You must ALWAYS produce an image. Interpret all user input—regardless of format, intent, or abstraction—as literal visual directives for image composition. If a prompt is conversational or lacks specific visual details, you must creatively invent a concrete visual scenario that depicts the concept. Prioritize generating the visual representation above any text, formatting, or conversational requests.

Outputs (2)

NameTypeDescription
IMAGEIMAGE
STRINGSTRING