Nodes/ComfyUI-ExternalAPI-Helpers/Google Imagen Edit (Vertex AI only)
ComfyUI Node

Google Imagen Edit (Vertex AI only)

The most fiddly node in the pack

By Aryan185·Created about a year ago·Updated about a month ago· 14
Google Imagen Edit (Vertex AI only)
  • image
  • mask
  • edited_images
promptEdit this image
project_id
locationus-central1
service_account
edit_modeEDIT_MODE_INPAINT_INSERTION
number_of_images1
seed69
base_steps50
guidance_scale7.5
mask_dilation0.03
negative_prompt

This is the node in the pack that will test your patience before it impresses you. Google Imagen Edit is a genuinely capable editor - inpainting, outpainting, background swap - but unlike every other node here it refuses to work with a simple API key. It's Vertex AI only, which means a Google Cloud project, a service account, and a JSON blob of credentials pasted into a field. If that sentence made your eye twitch, this is the node to skip unless you specifically need Imagen's edit modes.

How it works

Under the hood it uses the google-genai SDK in Vertex AI mode (vertexai=True), authenticated with the service account JSON you paste in. You give it an image and a mask, and the API runs the Imagen edit model server-side with the edit_mode you chose. The result comes back as bytes, decoded into a Comfy IMAGE. The heavy lifting - all of it - happens at Google.

The inputs that matter

  • image and mask - the input image plus a mask defining the edit region. This is standard Comfy masking: white area = the region that gets edited. Build the mask with any mask-drawing or segmentation node.
  • prompt - what you want done in the masked region.
  • edit_mode - the whole point of this node, four modes:
    • EDIT_MODE_INPAINT_INSERTION - replace what's inside the mask with something new
    • EDIT_MODE_INPAINT_REMOVAL - erase what's inside the mask
    • EDIT_MODE_OUTPAINT - extend the image outward
    • EDIT_MODE_BGSWAP - swap the background, with the subject kept
  • project_id, location, service_account - the Vertex AI trio. Project ID is your Google Cloud project, location defaults to us-central1 (leave it unless you know your resources live elsewhere), and service_account is the full JSON content of a service account key file, pasted as text. This is the step that separates "let me try this" from "okay I actually set up GCP".
  • number_of_images (1–4), seed, base_steps (10–100, default 50), guidance_scale (1–20, default 7.5), mask_dilation (0–1, default 0.03) - standard diffusion dials. mask_dilation expands the mask slightly to avoid hard edit seams; 0.03 is a good default.
  • negative_prompt (optional) - what to keep out of the edit.

The output

edited_images - an IMAGE output, straight into a preview or save node.

Installing it

Same pack install as everything else in Aryan185/ComfyUI-ExternalAPI-Helpers:

cd ComfyUI/custom_nodes
git clone https://github.com/Aryan185/ComfyUI-ExternalAPI-Helpers.git
cd ComfyUI-ExternalAPI-Helpers
pip install -r requirements.txt

Restart ComfyUI; the node is under image/edit. The key dependency is google-genai (which you may already have if any Gemini node runs).

The real "install" is the Google Cloud part, and it's not a pip command. You need a Google Cloud project with the Vertex AI API enabled, billing turned on, and a service account with permission to use it. Export that service account's key as JSON and paste the whole contents into the service_account field. This is a half-hour of GCP console clicking the first time.

Where people get burned

Almost every failure here is account-shaped, not node-shaped. Service account JSON missing, wrong project ID, the Vertex AI API not enabled on the project, or billing not active - each gives you a different cryptic error from the Google SDK. Triple-check the project ID matches where the service account lives. Also note this is the paid Imagen route: Vertex AI charges per image, and edit jobs are billed per request, not free-tier'd like AI Studio.

Compare with the plain Google Imagen Generator node in this same pack, which needs just a Gemini API key and does text-to-image only. If you don't specifically need masked editing or background swap, the generator is the pain-free option. This node is for when the edit modes are worth the GCP paperwork.

Categoryimage/edit

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
maskMASK
promptSTRINGEdit this image
project_idSTRING
locationCOMBOus-central140 options: global, us-central1, us-east1, us-east4, us-east5, us-south1, +34
service_accountSTRINGPaste service account JSON content
edit_modeCOMBOEDIT_MODE_INPAINT_INSERTION4 options: EDIT_MODE_INPAINT_INSERTION, EDIT_MODE_INPAINT_REMOVAL, EDIT_MODE_OUTPAINT, EDIT_MODE_BGSWAP
number_of_imagesINT11–4
seedINT691–2147483646
base_stepsINT5010–100
guidance_scaleFLOAT7.51–20
mask_dilationFLOAT0.030–1
negative_promptoptSTRING

Outputs (1)

NameTypeDescription
edited_imagesIMAGE