Stability Replace Background and Relight
New background, new light, one async call
- subject_image
- background_reference
- light_reference
- IMAGE
This is the most ambitious node in the pack, and the name says exactly what it does: cut your subject out, put a new background behind it, and re-light the whole thing to match. Product shots, portraits, "put this vase in a museum at golden hour" - that's the territory. It calls stable-image/edit/replace-background-and-relight on Stability's servers, and it's the most configurable edit node they ship, which also makes it the one with the most ways to go wrong.
It's a cloud node from the official "Stability API nodes for ComfyUI" pack: credits per call, API key required, zero VRAM. Locally, this job is a pipeline - cutout, composite, and an IC-Light pass for the relighting - and IC-Light is a good mental model for what the server is doing here, including its weaknesses. The community has been meh on this whole pack ("not local, not interested"), and this is the node where that sentiment is most justified if you have the local stack. It's also where the cloud earns its keep, because the local equivalent is genuinely multi-step and fiddly.
How it works
The one required input is subject_image - the thing to keep. The background comes from one of two places: a background_reference image, or a background_prompt describing the new scene. Then you steer the edit:
- preserve_original_subject (0.0–1.0, default 0.6) - how faithfully the subject survives the compositing. If your subject morphs or gets restyled, raise this.
- keep_original_background (boolean) - composite the subject onto its own original background, purely for the relighting pass. Useful when you only want the light fixed.
- original_background_depth (0.0–1.0, default 0.5) - how much the original background's depth is preserved when generating the replacement. Mostly a realism dial.
- foreground_prompt - optionally describe the subject so the model handles it better.
- The lighting block: light_source_direction (none/above/below/left/right), light_source_strength (0.0–1.0, default 0.3), and light_reference - an image whose lighting you want to borrow. For product shots, a
light_referenceof the studio setup you're mimicking is the secret weapon. - negative_prompt, seed, output_format - the standard furniture.
Like Creative Upscale, this route is async: it submits, then polls Stability's results endpoint for up to about four minutes. Big jobs make it feel slow. Plan for the wait.
Output is a single IMAGE tensor.
Installing it
From the "Stability API nodes for ComfyUI" pack - ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Stability-AI/ComfyUI-SAI_API
# restart ComfyUI
No model downloads; requests is the only dependency beyond ComfyUI's own stack. Key via SAI_API_KEY, a sai_platform_key.txt file, or the per-node api_key_override (which embeds the key in the workflow - don't share those files).
Common issues
- Subject gets relit into something unrecognizable - raise
preserve_original_subject; the relighting can get aggressive the way IC-Light does, especially on skin. Keep the light strength modest and check whatlight_source_directionis doing. - The wait feels like a hang - it's polling, up to ~240 seconds. That's the async design.
- Background has nothing to do with your reference - if you supplied both a
background_referenceand abackground_prompt, they can fight. Pick one source of truth. - "payment_required" - credits ran out; this is a heavier job than the single-image edits, so the bucket drains faster.
When it works, it's a genuinely impressive one-node product-shot machine. When it doesn't, it's usually the subject preservation or the lighting fighting you - and those are both dials you control.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| subject_image | IMAGE | — | |
| background_referenceopt | IMAGE | — | |
| background_promptopt | STRING | — | |
| foreground_promptopt | STRING | — | |
| negative_promptopt | STRING | — | |
| preserve_original_subjectopt | FLOAT | 0.600–1 | — |
| original_background_depthopt | FLOAT | 0.500–1 | — |
| keep_original_backgroundopt | BOOLEAN | false | — |
| light_source_directionopt | COMBO | 5 options: none, above, below, left, right | |
| light_referenceopt | IMAGE | — | |
| light_source_strengthopt | FLOAT | 0.300–1 | — |
| seedopt | INT | 00–4294967294 | — |
| output_formatopt | COMBO | 3 options: png, webp, jpeg | |
| api_key_overrideopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |