ComfyUI Node

NAI Img2Img

Re-roll a local image with NovelAI's closed models

By raspie10032·Created about a year ago·Updated a day ago· 7
NAI Img2Img
  • image
  • 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

Same cloud-model idea as the pack's NovelAIGenerator, but with an image on the input. NAIImg2ImgNode takes an existing image, resizes it to your chosen dimensions, and sends it to NovelAI's API to be re-rendered under your prompt at a set strength. It's how you take a draft you made locally - or in another ComfyUI model - and give it a pass through NAI's V5 or V4.5.

The use cases are the familiar img2img ones, just pointed at a closed model: restyle an image you like, nudge a composition into place, or chain a local generation into NAI's tag-following for the final look. It costs Anlas per call and your source image leaves the machine, same as every node in this pack.

How it works

The node takes your IMAGE, resizes it with Lanczos to exactly your width × height, base64-encodes it, and stuffs it into the img2img request along with strength and an optional noise value. The API runs a full denoising pass over that image at the given strength and returns a ZIP-wrapped PNG, which the node unpacks, autosaves under output/<date>/NAI_autosave/ (prefixed NAI_i2i), and returns as an IMAGE.

Two details matter. First, the resize happens before the request - if you feed it a 1024×1536 image but set width/height to 832×1216, you get a 832×1216 result, not a crop and not a surprise. The defaults are the usual portrait anime dims; anything must be a multiple of 64. Second, strength is the denoise amount (0–1, default 0.5): low keeps your source nearly intact, high lets the model redraw. noise (optional, 0–1, default 0) adds extra noise before sampling, which loosens the tie to the source a bit - useful when the model clings too hard to the input.

The inputs

Required: image, prompt, negative_prompt, model (same eight-way dropdown as the generator), width/height, sampler, steps, cfg_scale, strength, seed (-1 random). Optional: scheduler (karras default), cfg_rescale, prefer_brownian, noise, variety_boost (default on; maps to skip_cfg_above_sigma for varied outputs), characterPrompts (a LIST from CharacterPromptSelect, V4/V5 only), and limit_opus_free (default True - caps pixels at 1,048,576 and steps at 28; flip to False on a paid plan).

Output is a single IMAGE.

Install

With the rest of the pack. ComfyUI Manager → Custom Nodes Manager → search ComfyUI_RS_NAI_API_Request → Install, restart. Or:

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

Before any generation node runs you need a token in ComfyUI_RS_NAI_API_Request/.env:

NAI_ACCESS_TOKEN=your_token_here

(NAI_API_TOKEN works as a fallback.)

Common issues

  • Image comes back at the wrong size - you set width/height wrong, or limit_opus_free scaled them down to stay under the free-tier pixel cap. Set the dimensions you want and, on a paid account, turn the limit off.
  • Result is too close to / too far from the source - that's strength, pure and simple. 0.3–0.4 for light edits, 0.6+ for a serious redraw.
  • 429 rate limiting - the node sleeps 60 seconds and retries once; on the free tier the caps are doing their job.
  • Request rejected with no image - Anlas balance or subscription trouble; the API decides, not the node, and the error prints in the console.

One caveat: the request batching is fixed at a single sample, so run it per-image and seed-sweep outside the node if you want variations.

CategoryRS_NovelAI_API/Generation

Inputs (18)

NameTypeDefaultDescription
imageIMAGE
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