ComfyUI Node

NAI Inpaint

Inpaint through NovelAI with a plain ComfyUI mask

By raspie10032·Created about a year ago·Updated 2 days ago· 7
NAI Inpaint
  • image
  • mask
  • characterPrompts
  • IMAGE
promptprompt here
negative_promptlowres, bad anatomy
modelNAI Diffusion V5 Curated
width832
height1216
samplerk_euler
steps28
cfg_scale6.0
strength0.50
seed-1
schedulerkarras
cfg_rescale0.00
prefer_brownianfalse
noise0.00
variety_boosttrue
limit_opus_freetrue

Every ComfyUI user knows the inpainting loop: paint a mask over the broken bit, re-render just that region, done. NAIInpaintNode is that same loop pointed at NovelAI's cloud models - you feed it an image and a standard MASK (white = repaint), and it ships the masked image to NAI's inpainting endpoint and returns the result as an IMAGE.

Reach for it when the thing you're fixing would look better with NAI's model doing the repaint than your local checkpoint. The canonical case is exactly the one the masking doc hammers: a face or hand that came out mangled at small size, or an object you want to swap out. It's also what the pack's own Face Detailer leans on internally, so if you've used that, you've already used this.

How it works

The node takes your image and mask, snaps width/height down to multiples of 64, resizes both (the image with Lanczos, the mask with nearest-neighbor so edges stay hard), base64-encodes them, and sends an infill request. The strength input maps to NovelAI's inpaintImg2ImgStrength - the denoise applied inside the mask region. The response is a ZIP-wrapped PNG, autosaved under output/<date>/NAI_autosave/ (prefix NAI_inpaint), and returned as an IMAGE.

The model handling has one genuinely useful quirk. V5 Full uses its native V5 inpainting model, but V5 Curated's inpainting variant isn't released yet, so selecting V5 Curated silently falls back to the V4.5 Curated inpainting model - which is exactly what NovelAI's own client does. So you can pick V5 Curated for generation and still get working inpaint behavior; it's just V4.5 under the hood until NAI ships the real thing.

The inputs

Required: image, mask (white = repaint), prompt, negative_prompt, model, width/height, sampler, steps, cfg_scale, strength, seed. Optional: scheduler, cfg_rescale, prefer_brownian, noise (extra noise before sampling), variety_boost (default on), characterPrompts (a CharacterPromptSelect list, V4/V5 only), and limit_opus_free (default True; flip to False on a paid plan).

The two you'll actually tune are strength and the mask. Start around 0.5; if the repainted patch doesn't blend, drop it toward 0.3–0.4. The noise input is your escape hatch when the model reproduces the masked area too literally.

Output is a single IMAGE.

Install

Part of ComfyUI_RS_NAI_API_Request. ComfyUI Manager (search the pack title) → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/raspie10032/ComfyUI_RS_NAI_API_Request.git
pip install -r requirements.txt

Token required before any generation node runs - a .env in the node directory with NAI_ACCESS_TOKEN=... (or NAI_API_TOKEN).

Common issues

  • Nothing happens around the mask - mask convention. White = repaint. If you fed it a black-on-white mask from a node that uses the opposite convention, flip it.
  • Result is the wrong size - dims snap to 64 and limit_opus_free can scale them down further. On a paid account turn the limit off.
  • Patch edges show - inpainting seam, not a bug. Drop strength, and feather/pad the mask before it hits this node; the mask is resized nearest-neighbor, so it has no softening of its own.
  • 429 or rejected request - rate limit (node sleeps 60s and retries once) or Anlas/subscription trouble; the API decides, the console shows the error.

Worth saying plainly: every inpaint call costs Anlas, and your source image goes to NovelAI's servers. For one-off fixes that's a fair price; for batch repair at volume, a local inpainting model is still the cheaper, more private default.

CategoryRS_NovelAI_API/Generation

Inputs (19)

NameTypeDefaultDescription
imageIMAGE
maskMASK
promptSTRINGprompt here
negative_promptSTRINGlowres, bad anatomy
modelCOMBONAI Diffusion V5 Curated8 options: NAI Diffusion V5 Curated, NAI Diffusion V5 Full, NAI Diffusion V4.5 Curated, NAI Diffusion V4.5 Full, NAI Diffusion V4 Full, NAI Diffusion V4 Curated Preview, +2
widthINT83264–4096
heightINT121664–4096
samplerCOMBOk_euler7 options: k_dpmpp_2m, k_dpmpp_sde, k_dpmpp_2m_sde, k_dpmpp_2s_ancestral, k_euler_ancestral, k_euler, +1
stepsINT281–50
cfg_scaleFLOAT6.00–30
strengthFLOAT0.500–1
seedINT-1-1–4294967295
scheduleroptCOMBOkarras4 options: native, karras, exponential, polyexponential
cfg_rescaleoptFLOAT0.000–1
prefer_brownianoptBOOLEANfalse
noiseoptFLOAT0.000–1
variety_boostoptBOOLEANtrue
characterPromptsoptLIST
limit_opus_freeoptBOOLEANtrue

Outputs (1)

NameTypeDescription
IMAGEIMAGE