Nodes/ComfyUI_Prompt-All-In-One/API Gemini Image Gen
ComfyUI Node

API Gemini Image Gen

An API that drops a real image tensor back into your graph

By billwuhao·Created about a year ago·Updated about a year ago· 56
API Gemini Image Gen
  • image
  • image
  • text
api_key
prompt
modelgemini-2.0-flash-exp-image-generation
proxyhttp://127.0.0.1:None
temperature0.90
top_p0.90
top_k40
max_output_tokens2048
seed0

Most API nodes in this pack return text. This one returns an actual image - a real IMAGE tensor that you can wire straight into a Save Image node, an upscaler, or a Detailer, exactly as if a local sampler had made it. That's the whole point of API Gemini Image Gen: Google's Gemini image-generation model runs on their servers, and the node converts the returned pixels back into something the rest of your graph can keep working on.

The obvious workflow is text-to-image: give it a prompt, get a Google-quality image without touching your GPU. But the hidden feature is the optional image input - feed a reference image alongside your prompt and you're doing image editing / guided generation on a model that's actually good at following instructions. That's the workflow where this node shines: local diffusion for the base look, Gemini for an edit pass that understands a sentence. Cost is per call and your prompt/image leave the machine (both covered at length in external-api-nodes.md), so use it for what local can't do, not for everything.

How it works

It calls Google's google-genai client with response_modalities=['Text', 'Image'] - the magic flag that tells Gemini to actually draw. The response is parsed for parts: inline image bytes become the output IMAGE tensor, and any text becomes the text output. The two model choices are gemini-2.0-flash-exp-image-generation (default) and gemini-2.0-flash-preview-image-generation - Google's image-generation models. Unlike the DeepSeek and Qwen nodes, the seed here genuinely reaches the API (it's passed in the generation config), so you get some repeatability. Key is GOOGLE_API_KEY or the field.

The inputs that matter

  • prompt (multiline) - the description. With an optional image wired in, describe the edit you want.
  • image (IMAGE, optional) - a reference for editing/guided generation.
  • model - pick the exp or preview image-gen build.
  • temperature / top_p / top_k - sampling knobs; defaults (0.9/0.9/40) are fine to leave alone.
  • max_output_tokens - cap on the response (2048 default).
  • seed - actually used here. Set it if you want to retry the same composition.
  • proxy - see below; this field is the gotcha.

Outputs: image (IMAGE) and text (STRING). Wire image into Save Image / Preview; text into a text viewer if you want to see what Gemini said alongside the picture.

Installing it

Part of ComfyUI_Prompt-All-In-One (billwuhao). ComfyUI Manager → search Prompt-All-In-One, or:

cd ComfyUI/custom_nodes
git clone https://github.com/billwuhao/ComfyUI_Prompt-All-In-One.git
cd ComfyUI_Prompt-All-In-One
pip install -r requirements.txt

Restart; it's under 🎤MW/MW-Prompt-All-In-One.

Where people get burned

The proxy field is the trap. In the source, the guard that decides whether to set http_proxy/https_proxy environment variables is written with or where it should be and - so it fires on every run, even when you leave the field at its bizarre default http://127.0.0.1:None. If you get proxy-related connection errors and you never meant to use a proxy, this field is the first suspect; it's also where you'd put a real proxy if you're in a region where Google's API needs one. Separately: if you want Gemini's newest image model, this node's dropdown is pinned to the 2.0 flash generation builds - the flash model families changed a lot through 2025, so check the dropdown against what Google is currently offering rather than assuming "Gemini image gen" means the newest thing. And the standing caveat - this is the category that has shipped malware once (comfyui-ecosystem.md), and your key is sitting in a field that travels with the workflow. Prefer the env var, and don't share the workflow file with the key pasted in.

Category🎤MW/MW-Prompt-All-In-One

Inputs (10)

NameTypeDefaultDescription
api_keySTRING
promptSTRING
modelCOMBOgemini-2.0-flash-exp-image-generation2 options: gemini-2.0-flash-exp-image-generation, gemini-2.0-flash-preview-image-generation
proxySTRINGhttp://127.0.0.1:None
temperatureFLOAT0.900–1.5
top_pFLOAT0.900–1
top_kINT400–100
max_output_tokensINT20480–32768
seedINT00–268435455
imageoptIMAGE

Outputs (2)

NameTypeDescription
imageIMAGE
textSTRING