Nodes/ComfyUI-YCYY-API/Gemini Image API
ComfyUI Node

Gemini Image API

Run Google's Gemini image model without downloading anything

By ycyy·Created 11 months ago·Updated 3 days ago· 11
Gemini Image API
  • images
  • config_options
  • proxy_options
  • IMAGE
  • STRING
prompt
modelgemini-2.5-flash-image
aspectRatioauto
imageSize1K
enableSearchfalse
seed0

This is the node that drops Google's Nano Banana - Gemini 2.5 Flash Image - into a ComfyUI graph. No model download, no VRAM, no local pipeline: you type a prompt, it phones Google's API, and the finished image lands back as a regular ComfyUI IMAGE tensor. Want to edit an existing render, keep a character consistent across a few reference shots, or render clean text into an image? That's Nano Banana's party trick, and this is the least painful way to get it into your workflows.

A quick honesty note on the model itself: Gemini image generation is technically great. The Pro variant (gemini-3-pro-image-preview) does native 4K output, up to 14 reference images, and multi-language text rendering. It's also heavily censored - Google filters hard on IP, celebrities, and whatever you were just about to try. That's the model's doing, not this node's, but go in with realistic expectations.

How it works

The node is a thin REST client. It POSTs your prompt to {base_url}/{model}:generateContent with responseModalities: ["TEXT", "IMAGE"], then decodes the base64 image out of the JSON response back into a ComfyUI tensor.

Feed nothing into images and it's text-to-image. Plug an image (or several) into the optional images input and it switches to edit mode - it sends them as base64 PNG inline data alongside your prompt, which is how you get "put this character in a rainstorm" style edits. That's the same mechanism Nano Banana uses for its character-consistency and image-fusion tricks. Every result carries an invisible SynthID watermark, so don't expect clean provenance-free output.

The inputs that matter

Most of the node is optional. You'll actually touch these:

  • prompt - the thing you want, as plain language. This is a Gemini-native model; write like you're talking to a smart assistant, not a tag soup.
  • model - a combo populated from config.json. Defaults to gemini-2.5-flash-image (Nano Banana); the example config also ships gemini-3-pro-image-preview and gemini-3.1-flash-image-preview.
  • aspectRatio - defaults to auto, which matches the size of your input image or falls back to 1:1. The other options (2:3, 3:2, 9:16, 16:9, 21:9, …) force a shape.
  • imageSize - 1K/2K/4K. The tooltip and the code agree here: only the gemini-3 models actually honor this; 2.5-flash-image ignores it.
  • enableSearch - gemini-3 only; lets the model use Google Search for up-to-date info while generating.

One honest gotcha from reading the source: the seed input is accepted by the UI but never actually sent to the API. It's threaded through the code and dropped. So don't expect seeds to reproduce results here - rerolls are just re-rolls.

Outputs

You get two: IMAGE (wire it into Save Image, a preview, or anything downstream that eats images) and STRING, a small JSON status blob - {"success":true,"message":"total_tokens:..."} on success, or {"success":false,"message":"..."} with the API's reason on failure.

That STRING output is your diagnostics. When something goes wrong the node doesn't raise - it hands you a black 512×512 image and puts the real error in the string.

Installing it

This pack is several API clients in one, and the setup is the same for all of them:

cd ComfyUI/custom_nodes
git clone https://github.com/ycyy/ComfyUI-YCYY-API

Or search "ComfyUI-YCYY-API" in ComfyUI Manager. Then the step everyone forgets: copy config.json.example to config.json inside the pack folder and put your key in. The gemini-image section wants a base_url ending in v1beta/models and your Google AI Studio api_key. No model files, no GPU, no new Python deps - everything the node imports (requests, torch, numpy, Pillow) ships with ComfyUI. Restart and you'll find the nodes under YCYY/API.

Where people get burned

  • No config.json - the node throws Config file not found. The example config is not auto-copied; you have to do it.
  • The proxy trap - the example config includes a proxy section pointing at http://127.0.0.1:7890 (a typical Clash port). It ships disabled, but if you flip it on without a local proxy running, every request fails mysteriously. Leave it off unless you actually tunnel.
  • Rate limits - the free AI Studio tier 429s fast, and the Pro model can be slow; the default timeout is 120s.
  • Third-party relays - the README explicitly supports Gemini-compatible interfaces. Using a relay? Just change base_url and the model name. Same node, different backend.

And remember you can override base_url, api_key, and timeout per-node with the pack's YCYY API Config Options node rather than editing JSON - handy when you juggle multiple keys.

CategoryYCYY/API/image

Inputs (9)

NameTypeDefaultDescription
promptSTRING
modelCOMBOgemini-2.5-flash-image1 options: gemini-2.5-flash-image
aspectRatioCOMBOautoThe model defaults to matching the output image size to that of your input image, or otherwise generates 1:1 squares. You can control the aspect ratio of the output image using the aspect ratio
imageSizeCOMBO1KControl the resolution of the output image. 1K is approximately 1024x1024, 2K is approximately 2048x2048, 4K is approximately 4096x4096(Only effective for the gemini-3 model).
enableSearchBOOLEANfalseUse the Google Search tool to generate images based on real-time information(Only effective for the gemini-3 model)
seedINT00–18446744073709550000
imagesoptIMAGEOptional image(s) to use as context for the model
config_optionsopt*Optional configuration override from YCYY API Config Options
proxy_optionsopt*Optional proxy configuration override from YCYY API Proxy Options

Outputs (2)

NameTypeDescription
IMAGEIMAGE
STRINGSTRING