Nodes/Comfyui-Z-Image-Utilities/Z-Image Integrated KSampler
ComfyUI Node

Z-Image Integrated KSampler

LLM-enhance, sample, save

By Koko-boya·Created 9 months ago·Updated 6 months ago· 127
Z-Image Integrated KSampler
  • model
  • clip
  • vae
  • config
  • options
  • image_1
  • image_2
  • image_3
  • image_4
  • latent
  • images
  • latent
  • enhanced_prompt
  • debug_log
positive_prompt
negative_prompt
generation_modetext_to_image
width1024
height1024
seed0
steps20
cfg7.0
sampler_nameeuler
schedulernormal
denoise1.00
prompt_templatechinese
enable_prompt_enhancetrue
batch_size1
auraflow_shift0.00
cfg_norm_strength0.00
enable_clean_gpufalse
enable_clean_ramfalse
auto_save_folder
output_prefixz_image
custom_system_prompt
instructionDescribe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate.

The name is doing a lot of work, but it's accurate: this node is the entire Z-Image generation stack collapsed into one box. Give it a model, a CLIP, a VAE, and a config from Z-Image API Config, type a short idea into positive_prompt, and it runs the LLM prompt enhancement, encodes with CLIP, samples, decodes, and hands you finished images. The pack's README shows the standalone equivalent as a four-node chain - API Config → Prompt Enhancer → CLIP Text Encode → KSampler - and this node is that chain, fused.

It's the flagship of Koko-boya's Comfyui-Z-Image-Utilities pack, built around Z-Image, Alibaba's 6B model that the community treats as the SDXL successor. If you just want Z-Image running with LLM-enhanced prompts and don't care to assemble the pieces yourself, this is the one you reach for.

How it works

Under the hood it calls the pack's own prompt enhancer (always statelessly, with no session history), then does the sampling itself. Two things are worth knowing because they're easy to trip over:

  • The defaults are generic ComfyUI, not Z-Image-optimized. steps defaults to 20, cfg to 7, sampler euler, scheduler normal. Those are fine numbers for an SDXL-era model, wrong for Turbo. Z-Image-Turbo is guidance-distilled: it wants ~8 steps at CFG 1, where a negative prompt barely matters. Z-Image Base wants the opposite - 25–50 steps at CFG 3–5 with real negative prompting. Set them for whichever variant you loaded.
  • auraflow_shift is the knob you'll actually fiddle. Set it above 0 and the node patches the model's sampling shift. The community's most repeated Turbo tweak is a shift of 7 (ComfyUI's default is 3), and the KB's Z-Image guide agrees. There's also cfg_norm_strength, a CFGNorm-style post-CFG rescale, but that's more of a power-user toy - most people leave it at 0.

generation_mode switches between text_to_image and image_to_image. I2I requires at least one of image_1 through image_4 connected; the node encodes the first image as your starting latent and uses the Z-Image pipeline's reference-latent conditioning, sending the images to a vision-capable LLM using the instruction field as its system prompt. denoise is your standard KSampler strength - drop it below 1 for lighter edits.

The inputs that matter

The required list is long but mostly self-explanatory: model/clip/vae come straight from a checkpoint loader, config from Z-Image API Config, then positive_prompt, negative_prompt, width, height, seed, steps, cfg, sampler_name, scheduler, denoise. The optional ones you'll actually touch:

  • enable_prompt_enhance - turn it off and your prompt is used as-is, which is handy when you've already written a full detailed prompt (the enhancer works best on short ones anyway).
  • options - plug in a Z-Image Options node to control the LLM's temperature, repeat penalty, and so on.
  • auto_save_folder - a folder name (relative paths land inside ComfyUI's output dir) plus output_prefix for the filename; empty disables saving.

Outputs and wiring

It returns images (wire into Preview Image or Save Image), latent (the denoised latent, useful for chaining a second pass), enhanced_prompt (the actual text the LLM produced - inspect it once to see what's going in), and debug_log for when things go wrong.

Installing and gotchas

Install via ComfyUI Manager (search "Comfyui-Z-Image-Utilities") or cd ComfyUI/custom_nodes && git clone https://github.com/Koko-boya/ComfyUI-Z-Image-Utilities.git, then restart. If you run the Direct provider (model loaded from HuggingFace) you'll also need pip install bitsandbytes huggingface-hub.

Two traps worth remembering: if you enable prompt enhancement, expect verbose, narrative output - that's normal and generally helps Z-Image. And the OpenRouter free-tier LLMs the config defaults to can rate-limit mid-run, so keep an eye on debug_log when output looks wrong.

CategoryZ-Image

Inputs (32)

NameTypeDefaultDescription
modelMODELDiffusion model for image generation
clipCLIPCLIP model for text encoding
vaeVAEVAE model for latent encode/decode
configZIMAGE_CONFIGLLM configuration for prompt enhancement
positive_promptSTRINGPositive prompt - will be enhanced by LLM
negative_promptSTRINGNegative prompt for unwanted elements
generation_modeCOMBOtext_to_imageT2I: Generate from text. I2I: Edit/transform input images
widthINT102464–8192Output image width
heightINT102464–8192Output image height
seedINT00–18446744073709550000Random seed
stepsINT201–1000Sampling steps
cfgFLOAT7.00–100CFG scale
sampler_nameCOMBOeulerSampler algorithm
schedulerCOMBOnormalScheduler type
denoiseFLOAT1.000–1Denoise strength (1.0 = full, <1.0 for I2I)
optionsoptZIMAGE_OPTIONSAdvanced LLM options
image_1optIMAGEFirst image for I2I/vision enhancement
image_2optIMAGESecond image (optional)
image_3optIMAGEThird image (optional)
image_4optIMAGEFourth image (optional)
latentoptLATENTOptional latent input (for custom latent)
prompt_templateoptCOMBOchineseLLM prompt template language
enable_prompt_enhanceoptBOOLEANtrueEnable LLM prompt enhancement (disable to use prompt as-is)
batch_sizeoptINT11–16Number of images to generate
auraflow_shiftoptFLOAT0.000–100AuraFlow shift (0 = disabled)
cfg_norm_strengthoptFLOAT0.000–10CFGNorm strength (0 = disabled)
enable_clean_gpuoptBOOLEANfalseClean GPU memory before/after sampling
enable_clean_ramoptBOOLEANfalseClean RAM after completion
auto_save_folderoptSTRINGAuto-save folder (empty = disabled)
output_prefixoptSTRINGz_imageFilename prefix for auto-save
custom_system_promptoptSTRING
instructionoptSTRINGDescribe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate.System instruction for the Vision-Language Model in I2I mode

Outputs (4)

NameTypeDescription
imagesIMAGE
latentLATENT
enhanced_promptSTRING
debug_logSTRING