ComfyUI Extension: ComfyUI_NAIDGenerator

Authored by bedovyy

Created

Updated

82 stars

This extension helps generate images through NAI.

README

ComfyUI_NAIDGenerator

A ComfyUI extension for generating images via the NovelAI API.

Installation

  • git clone https://github.com/bedovyy/ComfyUI_NAIDGenerator into the custom_nodes directory.
  • or 'Install via Git URL' from Comfyui Manager

Setting up NAI account

Before using the nodes, you should set NAI_ACCESS_TOKEN in a .env file located in your main ComfyUI directory.

ComfyUI/.env

NAI_ACCESS_TOKEN=<YOUR_ACCESS_TOKEN>

You can get a persistent API token by navigating to User Settings > Account > Get Persistent API Token on the NovelAI website.

Otherwise, you can get an access token which is valid for 30 days using novelai-api.

Usage

The nodes are located in the NovelAI category.

image

Txt2img

Simply connect the GenerateNAID node to a SaveImage node.

generate

Note: All generated images via the GenerateNAID node are automatically saved to output/NAI_autosave/NAI_autosave_#####_.png to preserve their original metadata.

Img2img

Connect an Img2ImgOptionNAID node to the option input of the GenerateNAID node and provide a source image.

image

Note: The width and height of the source image will be resized to the generation size.

Inpainting

Connect an InpaintingOptionNAID node to the GenerateNAID node and provide a source image and a mask.

image

Note: Both the source image and mask will be automatically resized to fit the generation size.

Vibe Transfer

Connect a VibeTransferOptionNAID node to the GenerateNAID node and provide a reference image to transfer its style and feel.

Comfy_workflow

You can also chain it with other options, like Img2Img.

image

Multiple Vibe Transfer

Connect multiple VibeTransferOptionNAID nodes to combine their influences.

preview_vibe_2

Character Reference

Use the CharacterReferenceOptionNAID node to guide the generation using a single reference image for character identity and/or style.

image

  • style_aware: If enabled, it attempts to copy both the character's features and the artistic style.
  • fidelity: Controls how strictly the generation should adhere to the reference image. The developers state that primary_strength is always kept at 1.0, while secondary_strength is calculated as $1.0 - \text{fidelity}$.

Note: The reference image will be automatically letterboxed to an accepted NAI canvas size to preserve its aspect ratio.

ModelOption

The default model of the GenerateNAID node is nai-diffusion-4-5-full. To change the model, connect a ModelOptionNAID node.

Available V4+ models include:

  • nai-diffusion-4-curated-preview
  • nai-diffusion-4-full
  • nai-diffusion-4-5-curated
  • nai-diffusion-4-5-full

ModelOption

NetworkOption

You can set timeout and retry options using the NetworkOption node. You can also set ignore_errors to prevent the queue from stopping on an API error; if an error occurs, a blank 1x1 image will be output.

preview_network

Note: If you set the timeout too short, you may not receive an image but could still be charged Anlas.

Anlas Tracker

This extension now includes Anlas tracking to monitor your usage.

1. Console Output (Automatic) All generation and director tool nodes will automatically print your Anlas balance before and after the operation in the console where you launched ComfyUI.

[NovelAI] Anlas (pre-gen): 10000
[NovelAI] Generation cost: 20 Anlas
[NovelAI] Anlas (post-gen): 9980

2. Visual Node A new node, Anlas Tracker ✒️🅝🅐🅘, is available in the NovelAI/utils category. You can use it to display your current Anlas balance directly in your workflow.

Connect its anlas_string output to a display node (e.g., "Show Text" from the WAS Node Suite) to see the value. Use the trigger input to control when the balance is checked.

image <!-- Placeholder for actual image -->

PromptToNAID

ComfyUI uses () or (word:weight) for emphasis, while NovelAI uses {} and []. This node, found in NovelAI/utils, converts ComfyUI's prompt syntax to NovelAI's.

image

Director Tools

image

You can find director tools like LineArtNAID, EmotionNAID, and RemoveBGNAID in the NovelAI/director_tools category.

augment_example

V4 / V4.5 Support

The nodes fully support NAI's V4 and V4.5 model architecture.

V4 Prompt Handling

Two new nodes have been added in NovelAI/v4 for V4/V4.5 prompt handling:

  • V4BasePrompt: Handles the positive prompt.
  • V4NegativePrompt: Handles the negative prompt.

Example V4 / V4.5 Workflow

Here's a basic setup for a V4/V4.5 model:

V4BasePrompt -----> positive
                           GenerateNAID
V4NegativePrompt -> negative

Note: Basic img2img, vibe transfer and inpainting functionality works with V4/V4.5.