Google Imagen Edit (Vertex AI only)
The most fiddly node in the pack
- image
- mask
- edited_images
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 newEDIT_MODE_INPAINT_REMOVAL- erase what's inside the maskEDIT_MODE_OUTPAINT- extend the image outwardEDIT_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), andservice_accountis 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_dilationexpands 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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| prompt | STRING | Edit this image | — |
| project_id | STRING | — | |
| location | COMBO | us-central1 | 40 options: global, us-central1, us-east1, us-east4, us-east5, us-south1, +34 |
| service_account | STRING | Paste service account JSON content | |
| edit_mode | COMBO | EDIT_MODE_INPAINT_INSERTION | 4 options: EDIT_MODE_INPAINT_INSERTION, EDIT_MODE_INPAINT_REMOVAL, EDIT_MODE_OUTPAINT, EDIT_MODE_BGSWAP |
| number_of_images | INT | 11–4 | — |
| seed | INT | 691–2147483646 | — |
| base_steps | INT | 5010–100 | — |
| guidance_scale | FLOAT | 7.51–20 | — |
| mask_dilation | FLOAT | 0.030–1 | — |
| negative_promptopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| edited_images | IMAGE | — |