Nodes/ComfyUI-Gemini-API/Gemini 2.0 image
ComfyUI Node

Gemini 2.0 image

The API wrapper that skips your GPU

By CY-CHENYUE·Created about a year ago·Updated about a year ago· 251
Gemini 2.0 image
  • images
  • image
  • API Respond
prompt
api_key
modelgemini-2.0-flash-preview-image-generation
aspect_ratioFree (自由比例)
temperature1.00
seed66666666

This node is a phone line, not a generator. The Gemini 2.0 image node from CY-CHENYUE's ComfyUI-Gemini-API pack hands your prompt to Google's Gemini image model over the API, waits for the image to come back, and drops it into your graph as a normal IMAGE tensor. No weights, no VRAM, no model downloads - the whole thing runs on Google's servers and your API key. If you've ever envied the reference-image fidelity of Gemini's native image gen (the thing that eventually grew into Nano Banana) but didn't want to leave ComfyUI to get it, this is the bridge.

It's a genuinely small pack: one node, one job. You reach for it when you want Gemini-quality generations or style-reference results as a stage inside a bigger ComfyUI workflow - generate a concept frame here, then upscale, inpaint, or edit it with local nodes downstream. The flip side is that every generation costs API money and sends your prompt (and reference images) to Google, so it's a spice node, not a daily driver for your whole pipeline.

How it works

Under the hood the node uses Google's google-genai client (>=1.5.0) to call generate_content with response_modalities=['Text', 'Image']. It builds a request from your prompt, converts any reference images to in-memory PNGs, and attaches them as inline data. When the response comes back it grabs the image bytes, converts them to a ComfyUI tensor, and also pipes the API's text reply into a second output.

Two things the source reveals that the README won't tell you. First, the model dropdown is basically decorative: the input lists gemini-2.0-flash-preview-image-generation and gemini-2.0-flash-exp, but the actual API call hardcodes models/gemini-2.0-flash-exp every time. Changing the model selector changes nothing. Second, aspect_ratio isn't a real parameter - the node rewrites your prompt with "generate a wide rectangular image…" etc. and hopes. The README admits the model doesn't always obey, and that's exactly what you'll see.

Inputs that matter

  • prompt (required): what you want, in plain English. Multiline.
  • api_key (required): your Google AI Studio key. Enter it once; the node saves it to gemini_api_key.txt in the pack's folder and reads it back on later runs, so you can leave the field blank after the first time.
  • images (optional): the star feature. It accepts a batch, so wire in one or many reference images - they're all sent to Gemini as style/editing guidance, and the node tells the model how many to expect.
  • temperature (0.0–2.0, default 1.0): lower is more literal, higher is more wild.
  • seed: 0 means "surprise me" - the node picks a random one; anything else is passed through for reproducible runs.

Outputs

Two: image (the generated IMAGE tensor - wire it to a preview, save, or upscaler) and API Respond (a STRING that mixes a processing log with the API's text response). The second one is your debug console: when something goes wrong, the error message lives there, not on your screen.

Installing

ComfyUI Manager: search "Gemini API" and hit install, then restart. Manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/CY-CHENYUE/ComfyUI-Gemini-API
# then, for a portable install:
..\..\..\python_embeded\python.exe -m pip install -r requirements.txt

Dependencies are light: google-genai, Pillow, requests, numpy, torch. No model files to fetch.

Where people get burned

  • No key, no image. The most common failure: you get a flat gray 512×512 placeholder out, and the real reason is in the API Respond string. Grab a key from Google AI Studio and make sure billing is enabled.
  • The model field is a lie (see above). Don't expect to switch to a different Gemini model from the dropdown.
  • Aspect ratio is a suggestion. If you need strict dimensions, crop or pad downstream.
  • Deprecation drift. Gemini 2.0 Flash image generation has been superseded by the Nano Banana line (Gemini 2.5/3 Flash Image), and the node targets an -exp model that can change behavior or phase out. If you hit odd "model not found" errors, that's Google shifting the target, not your install.
  • Privacy. Every reference image is uploaded to Google. Fine for your own art; not for client work without disclosure.
CategoryGoogle-Gemini

Inputs (7)

NameTypeDefaultDescription
promptSTRING
api_keySTRING
modelCOMBOgemini-2.0-flash-preview-image-generation2 options: models/gemini-2.0-flash-preview-image-generation, models/gemini-2.0-flash-exp
aspect_ratioCOMBOFree (自由比例)4 options: Free (自由比例), Landscape (横屏), Portrait (竖屏), Square (方形)
temperatureFLOAT1.000–2
seedoptINT666666660–2147483647
imagesoptIMAGE

Outputs (2)

NameTypeDescription
imageIMAGE
API RespondSTRING