Nodes/Stability API nodes for ComfyUI/Stability Search and Replace
ComfyUI Node

Stability Search and Replace

Find it by name, swap it by prompt — no mask drawing required

By Stability-AI·Created 2 years ago·Updated about a year ago· 64
Stability Search and Replace
  • image
  • IMAGE
search_prompt
prompt
negative_prompt
grow_mask3
seed0
stylefalse
style_preset
output_format
api_key_override

Search and Replace is the node that makes the rest of this pack feel like a party trick. You feed it an image, type what's in the frame ("the red sedan"), type what you want instead ("a vintage pickup truck"), and it finds the object and swaps it. No mask painting, no SAM clicks, no inpaint choreography. Locally that workflow means mask editor plus a segmentation model plus an inpainting pass plus patience. Here it's two text boxes and one call.

The catch, and it's a real one: this is a cloud node. It's part of Stability's official "Stability API nodes for ComfyUI" pack and it hits the stable-image/edit/search-and-replace endpoint on Stability's servers. Zero VRAM, zero model downloads - but also not free. You need a Stability API key, and every run spends credits. The community's verdict on this pack has been "not local, not interested" since day one, and that's fair if you have a GPU. Where these nodes genuinely win: you're out of VRAM, you want a specific edit model Stability never open-weighted, or you just want a one-sentence edit that would take you twenty minutes locally.

How it works

The model reads search_prompt as a locator, not a style hint. It grounds that description to pixels - find the region of the image that matches "the red sedan" - then regenerates that region to match prompt. That grounding is the clever bit, and it's why the search text needs to be specific about which instance when the frame has several: "the woman in the yellow jacket," not just "a person."

Three inputs actually matter:

  • search_prompt - what's there now. Be specific about location and attributes.
  • prompt - what replaces it. Describe the new object the way you'd prompt any image.
  • grow_mask - how many pixels the selection expands by, 0–20, default 3. Too low and you'll see a halo around your edit; too high and you start eating the neighbors. Start at the default and only move it when you see edge artifacts.

Everything else is the pack's shared furniture: seed for reproducible runs, negative_prompt if the model keeps adding something you hate, output_format (png is the safe default, webp/jpeg if you're shipping something small), and style plus style_preset - remember the preset is ignored unless you flip style on.

The output is a single IMAGE tensor. Wire it straight into a Save Image or Preview node; it also feeds happily into any downstream node that takes an image.

Installing it

Install the whole pack via ComfyUI Manager - search "Stability API nodes for ComfyUI" - or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Stability-AI/ComfyUI-SAI_API
# restart ComfyUI

No model files, no heavy dependencies; the only real requirement beyond ComfyUI's own stack is requests, which your install almost certainly already has.

Then give it a key. Three ways, in order of preference:

# 1. environment variable (best)
export SAI_API_KEY=sk-your-key-here
# 2. or drop a file called sai_platform_key.txt next to the node
# 3. or paste the key into the api_key_override field on the node

Option 3 is a trap in disguise - that key travels inside the workflow JSON, so sharing the workflow shares your key. Don't.

Common issues

  • "payment_required" error - you're out of credits. Stability hands out trial credits when you sign up, and they burn fast; check your dashboard.
  • Edits that look smeared - usually grow_mask too low or a vague search_prompt that grounded onto the wrong pixels. Make the search text disambiguate.
  • The node sits waiting - this route is synchronous so it should return in seconds, but a long timeout on a big image usually means the server is busy; the error text will tell you which API response you hit.

It's not the tool for people who want everything on their own hardware. It is the tool for when you want a specific edit done right in one step and you're willing to pay a few cents for the convenience.

CategoryStability

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
search_promptSTRING
promptSTRING
negative_promptoptSTRING
grow_maskoptINT30–20
seedoptINT00–4294967294
styleoptBOOLEANfalse
style_presetoptCOMBO17 options: 3d-model, analog-film, anime, cinematic, comic-book, digital-art, +11
output_formatoptCOMBO3 options: png, webp, jpeg
api_key_overrideoptSTRING

Outputs (1)

NameTypeDescription
IMAGEIMAGE