Nodes/ComfyUI API Toolkit/Gemini Outpaint
ComfyUI Node

Gemini Outpaint

Extend the canvas beyond its edges — Gemini outpainting that understands the scene

By IxMxAMAR·Created 5 months ago·Updated 2 months ago· 1
Gemini Outpaint
  • image
  • image
api_key
modelgemini-3.1-flash-image-preview
custom_model
directionright
prompt
system_instruction
aspect_ratioAUTO

You have a 1:1 portrait and you need a 16:9 hero shot. Or a wide establishing shot that stops three pixels past the subject. Local outpainting has always been the awkward cousin of inpainting - the diffusion model has to invent an entire new region with only the image edge as a hint, and it shows. This node hands the job to a Gemini image model instead, which means the extension is reasoned: it reads the scene - the lighting, the perspective, the style - and extends it in the direction you choose with a prompt telling it what's out there.

It's the node you reach for when the empty canvas matters more than a seamless texture patch: turning a square asset into a different aspect ratio, adding context around a subject, or fixing a badly-cropped composition before it goes into a video workflow. The output drops back into the graph as a normal image, ready for an upscaler or an img2vid pass.

How it works

Like the Inpaint node, this goes through generate_content with the image sent as a JPEG part and an instruction built from your choices - literally "Extend this image to the right. Fill the new area with: …". The model gets a system instruction to extend seamlessly while keeping style and context consistent, and the returned image stream is decoded back into a ComfyUI IMAGE tensor.

The mechanism detail that matters: outpainting direction is explicit, not inferred. You pick right, left, up, down, or all, and the model builds the new region in exactly that direction. all is your 1:1-to-wider trick, adding canvas on every side at once.

Inputs and outputs that matter

  • image - the source you're extending.
  • direction - which edge(s) to grow. The default is right, and the order you compose prompts and crops around it is the one thing that varies per workflow.
  • prompt - what lives in the new area. "A sunlit beach continuing to the horizon" beats nothing - an empty prompt means the model free-associates the extension.
  • aspect_ratio - the interesting control. Default AUTO lets the model decide; or lock it to a target like 16:9 or 9:16 and the output comes back composed to that ratio. That's the whole "reframe this asset" use case in one dropdown.
  • model - the same image-capable trio as Inpaint (gemini-3.1-flash-image-preview by default, Pro available for quality).

One output: image (IMAGE).

How to install it

Same pack-level install as everything in this collection:

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-API-Toolkit
cd ComfyUI-API-Toolkit
pip install -r requirements.txt

or "API Toolkit" from ComfyUI Manager. Gemini needs google-genai>=0.8.0 and a key (GEMINI_API_KEY env var or the node field). Nothing to download.

Common issues

The classic failure is a mismatched extension - the model invents content that doesn't match the lighting or perspective of the original. That's mostly a prompt problem: describe the extension in terms of the existing scene, and reach for the Pro model when Flash gets sloppy. If the result looks like a paste-job, aspect_ratio set to a target can actually help, because the model is composing the whole canvas to a known shape instead of improvising.

And the usual API-node realities: every queue is a paid image call (the pack's IS_CHANGED override makes sure the node re-runs each time), and Google's content filter applies - a closed, moderated model refuses what it refuses, with no local workaround.

CategoryAPI Toolkit/Gemini/Image

Inputs (8)

NameTypeDefaultDescription
api_keySTRINGGemini API key. Leave blank to use GEMINI_API_KEY env var.
modelCOMBOgemini-3.1-flash-image-previewImage-capable Gemini model for outpainting.
custom_modelSTRINGOverride with a custom model ID.
imageIMAGEThe source image to extend.
directionCOMBOrightDirection to extend the image.
promptSTRINGDescribe what should appear in the extended area.
system_instructionoptSTRINGSystem instruction for the outpainting model.
aspect_ratiooptCOMBOAUTOTarget aspect ratio after outpainting.

Outputs (1)

NameTypeDescription
imageIMAGE