Nodes/ComfyUI FSL Nodes/FSL Gemini Generate Image
ComfyUI Node

FSL Gemini Generate Image

FSL Gemini Generate Image — the advanced one with real inpainting

By fredlef·Created about a year ago·Updated 9 months ago· 13
FSL Gemini Generate Image
  • init_image
  • images
  • mask
  • mask_image
  • image
  • prompt
  • model
  • width
  • height
  • temperature
  • seed
  • seed_mode
  • metadata
prompt
modelgemini-3-pro-image-preview
width1024
height1024
aspect_ratio1:1
qualityStandard
temperature1.0
seed-1
enable_safetyfalse
use_init_imagetrue
use_imagesfalse
use_maskfalse
base_for_inpaintauto
output_promptfalse
invert_maskfalse
feather_radius0
mask_strength1.00
api_key

This is the maintained, advanced Gemini image node in the FSL pack - the one the README points you to if you need more than a text prompt. It's a full-featured wrapper around the Gemini image-generation REST API: inpainting with a real mask, init images, multiple reference images, quality/aspect controls, seed control, and a metadata output you can feed straight into the pack's saver. The lightweight FSLGeminiImageGenerator is the "just make an image" sibling; this is the editor.

How it works

The node builds a generateContent request with parts: your prompt (plus an injected resolution/aspect-ratio line), then optionally the base image, a mask, and extra reference images. The interesting part is how it does inpainting - instead of computing anything locally, it sends the base image and a mask PNG to the model and relies on Gemini's native understanding of masks ("modify ONLY pixels where the mask is white; keep black pixels exactly the same"). That's cloud-native inpainting, and it's worth sitting with: unlike a local inpaint pass that re-composites, the model genuinely leaves masked-out pixels untouched. The KB's inpainting.md notes mask-based editing has been getting squeezed by whole-image edit models - but this approach keeps the "only change what's masked" guarantee those models can't give you.

You have three image sources to juggle:

  • init_image - the primary base (usually your use_init_image toggle + wire).
  • images - an extra IMAGE input, used as reference images, or as the base when base_for_inpaint says so.
  • mask / mask_image - the edit region. mask takes a proper MASK tensor; mask_image accepts an image used as a mask. Both get feathered and strength-scaled in the node before upload.

The base_for_inpaint dropdown (auto / init_image / images) picks which one is "the thing being edited." In auto it uses init_image if present, else images. If you enable the mask but no base resolves, the node raises a clear error: "Inpaint requires a base image."

The inputs that matter

  • prompt + model - the standard pair. gemini-3-pro-image-preview default, gemini-2.5-flash-image as the cheaper/speed option.
  • quality - Standard asks for 1K-style resolution, High for 4K-style, both via prompt injection. Real resolution is capped by the API (~1K native for the flash models), so width/height really are metadata-only - the tooltip on those fields says exactly that.
  • seed - -1 randomizes (and the node tells you via the seed_mode output); any other value gives reproducible-ish output.
  • enable_safety - default false means the node explicitly sets BLOCK_NONE on all four harm categories. Flip to true to use Google's default filters.
  • invert_mask, feather_radius, mask_strength - the mask-fiddling controls. White = editable, black = preserved; invert swaps that; feather blurs the boundary; strength scales how strongly the mask "bites."

Outputs

The first output image is what you want. Behind it ride prompt, model, width, height, temperature, seed, seed_mode, and a metadata DICT - the metadata output exists precisely so you can wire it into FSLImageSaverWithMetadata and get a self-documenting PNG.

Install & troubleshooting

Manager → "ComfyUI FSL Nodes", or clone and pip install -r requirements.txt (the README's portable-Windows command is .\python_embeded\python.exe -m pip install --upgrade google-genai requests). No local weights. Key via widget or GEMINI_API_KEY env var.

Two classic failures: a RuntimeError from the node about not finding an inline image usually means a safety block or a dead/deprecated model - the code's own error message includes the finish reason. And long generations can hit HTTP timeouts; the node already uses a 180s request timeout with backoff on 429s, so if you're on slow generations, first try a newer model before blaming the node.

CategoryFSL Nodes

Inputs (22)

NameTypeDefaultDescription
promptSTRING
modelCOMBOgemini-3-pro-image-preview2 options: gemini-3-pro-image-preview, gemini-2.5-flash-image
widthINT102464–2048These values are used for metadata only. Actual image size is determined by 'aspect_ratio' and API limits (~1K max).
heightINT102464–2048These values are used for metadata only. Actual image size is determined by 'aspect_ratio' and API limits (~1K max).
aspect_ratioCOMBO1:1Request this aspect ratio via prompt injection.
qualityCOMBOStandardStandard requests 1K-style resolution. High requests 4K-style resolution via prompt injection.
temperatureFLOAT1.00–2
seedINT-1-1–2147483647
enable_safetyBOOLEANfalseIf true, enables default API safety filters. If false, attempts to disable safety filters (BLOCK_NONE).
use_init_imageBOOLEANtrue
use_imagesBOOLEANfalse
use_maskBOOLEANfalse
base_for_inpaintCOMBOauto3 options: auto, init_image, images
output_promptBOOLEANfalse
init_imageoptIMAGE
imagesoptIMAGE
maskoptMASK
mask_imageoptIMAGE
invert_maskoptBOOLEANfalse
feather_radiusoptINT00–64
mask_strengthoptFLOAT1.000–1
api_keyoptSTRING

Outputs (9)

NameTypeDescription
imageIMAGE
promptSTRING
modelSTRING
widthINT
heightINT
temperatureFLOAT
seedINT
seed_modeSTRING
metadataDICT