ComfyUI Node

NAI Img2Img

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

By raspie10032·Created about a year ago·Updated 10 days ago· 8
NAI Img2Img
  • image
  • characterPrompts
  • vibes
  • references
  • nai_context
  • image
  • nai_context
◄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►
◄normalize_vibe_strengthstrue►
◄save_formatPNG►
◄webp_quality90►
◄request_delay_seconds0.0►
◄use_context_settingstrue►
◄context_modeinherit_all►
◄override_promptfalse►
◄override_negative_promptfalse►
◄override_modelfalse►
◄override_samplerfalse►
◄override_stepsfalse►
◄override_cfg_scalefalse►
◄override_schedulerfalse►
◄override_cfg_rescalefalse►
◄override_prefer_brownianfalse►
◄override_variety_boostfalse►
◄override_characterPromptsfalse►

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 (38)

NameTypeDefaultDescription
imageIMAGE—
promptSTRINGprompt here—
negative_promptSTRINGlowres, bad anatomy—
modelCOMBONAI Diffusion V5 CuratedV5 Full Medium Effort always uses 14 steps, Euler Ancestral, zero CFG Rescale, and fixed Heavy Undesired Content. Custom base/character negative prompts are ignored. Prompt Guidance remains adjustable. Image-to-image and inpainting require limit_opus_free=False and can spend Anlas.
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—
characterPromptsoptLISTV5: up to 22 active character prompts; V4/V4.5: up to 6. V5 Curated inpainting uses V4.5 (6).
limit_opus_freeoptBOOLEANtrue—
vibesoptRS_NAI_VIBES—
referencesoptRS_NAI_REFERENCES—
normalize_vibe_strengthsoptBOOLEANtrueV4/V4.5 Vibe: scale strengths down if their absolute sum exceeds 1.0.
save_formatoptCOMBOPNGAutosave format. Preserves NovelAI generation information. No ComfyUI workflow is embedded.
webp_qualityoptINT901–100Used only for lossy WebP. Lossless WebP preserves pixels.
nai_contextoptNAI_CONTEXTConnect the previous NAI generation context. Carries prompts, characters and generation settings; seed, size, strength, references and Anlas protection stay local.
request_delay_secondsoptFLOAT0.00–3600Wait before each NovelAI request, including each detail region and uncached Vibe encoding. 0 adds no delay. The built-in 2-second gap overlaps this timer; a longer server retry wait still applies. Preview-only runs do not wait. Stop cancels the countdown.
use_context_settingsoptBOOLEANtrueUse connected prompts, characters, model and sampling settings. Turn off to use this node's manual values. Seed always uses this node's setting.
context_modeoptCOMBOinherit_allWith context enabled, inherit everything or replace only checked fields with this node's values. Unchecked fields still come from context.
override_promptoptBOOLEANfalseUse this node's prompt in override_selected mode. An empty string, zero or False is an intentional replacement.
override_negative_promptoptBOOLEANfalseUse this node's negative_prompt in override_selected mode. An empty string, zero or False is an intentional replacement.
override_modeloptBOOLEANfalseUse this node's model in override_selected mode. An empty string, zero or False is an intentional replacement.
override_sampleroptBOOLEANfalseUse this node's sampler in override_selected mode. An empty string, zero or False is an intentional replacement.
override_stepsoptBOOLEANfalseUse this node's steps in override_selected mode. An empty string, zero or False is an intentional replacement.
override_cfg_scaleoptBOOLEANfalseUse this node's cfg_scale in override_selected mode. An empty string, zero or False is an intentional replacement.
override_scheduleroptBOOLEANfalseUse this node's scheduler in override_selected mode. An empty string, zero or False is an intentional replacement.
override_cfg_rescaleoptBOOLEANfalseUse this node's cfg_rescale in override_selected mode. An empty string, zero or False is an intentional replacement.
override_prefer_brownianoptBOOLEANfalseUse this node's prefer_brownian in override_selected mode. An empty string, zero or False is an intentional replacement.
override_variety_boostoptBOOLEANfalseUse this node's variety_boost in override_selected mode. An empty string, zero or False is an intentional replacement.
override_characterPromptsoptBOOLEANfalseReplace the complete character list with characterPrompts, including negatives and positions. No connection clears the list.

Outputs (2)

NameTypeDescription
imageIMAGE—
nai_contextNAI_CONTEXT—