invoke-ai/InvokeAI · error · TypeError
Expected AutoencoderKL or FluxAutoEncoder for Z-Image VAE, g
Error message
Expected AutoencoderKL or FluxAutoEncoder for Z-Image VAE, got {type(vae_info.model).__name__}. Ensure you are using a compatible VAE model. What it means
In the Z-Image latents-to-image (decode) invocation, the loaded VAE is type-checked before decoding: it must be diffusers AutoencoderKL or FluxAutoEncoder. Any other VAE class means the selected model cannot decode Z-Image latents, so a TypeError is raised instead of producing garbage images. The check also determines the is_flux_vae branch used for decoding context.
Source
Thrown at invokeai/app/invocations/z_image_latents_to_image.py:50
title="Latents to Image - Z-Image",
tags=["latents", "image", "vae", "l2i", "z-image"],
category="latents",
version="1.1.0",
classification=Classification.Prototype,
)
class ZImageLatentsToImageInvocation(BaseInvocation, WithMetadata, WithBoard):
"""Generates an image from latents using Z-Image VAE (supports both Diffusers and FLUX VAE)."""
latents: LatentsField = InputField(description=FieldDescriptions.latents, input=Input.Connection)
vae: VAEField = InputField(description=FieldDescriptions.vae, input=Input.Connection)
@torch.no_grad()
def invoke(self, context: InvocationContext) -> ImageOutput:
latents = context.tensors.load(self.latents.latents_name)
vae_info = context.models.load(self.vae.vae)
if not isinstance(vae_info.model, (AutoencoderKL, FluxAutoEncoder)):
raise TypeError(
f"Expected AutoencoderKL or FluxAutoEncoder for Z-Image VAE, got {type(vae_info.model).__name__}. "
"Ensure you are using a compatible VAE model."
)
is_flux_vae = isinstance(vae_info.model, FluxAutoEncoder)
# Estimate working memory needed for VAE decode
estimated_working_memory = estimate_vae_working_memory_flux(
operation="decode",
image_tensor=latents,
vae=vae_info.model,
)
# FLUX VAE doesn't support seamless, so only apply for AutoencoderKL
seamless_context = (
nullcontext() if is_flux_vae else SeamlessExt.static_patch_model(vae_info.model, self.vae.seamless_axes)
)
View on GitHub (pinned to 0b6a024f2f)
Solutions
- Point the VAE field at the Z-Image VAE (AutoencoderKL) or a FLUX VAE (FluxAutoEncoder).
- Use ZImageModelLoader with a Diffusers Z-Image source so the correct VAE submodel is resolved automatically.
- Correct the model's base/type metadata in the Model Manager if the right file is misregistered.
- Update InvokeAI if you believe this VAE should be supported.
Example fix
// before vae = ModelField(id='sd3-vae') // after vae = ModelField(id='flux-vae') # or z-image AutoencoderKL VAE
Defensive patterns
Strategy: type-guard
Validate before calling
cfg = context.models.get_config(latents_to_image.vae.vae)
assert cfg.base in (BaseModelType.ZImage, BaseModelType.Flux), f"VAE {cfg.name} is {cfg.base}, not usable for Z-Image decode" Type guard
from diffusers import AutoencoderKL
from invokeai.backend.flux.vae import FluxAutoEncoder
def can_decode_zimage_latents(vae) -> bool:
return isinstance(vae, (AutoencoderKL, FluxAutoEncoder)) Try / catch
try:
out = z_image_l2i.invoke(context)
except TypeError as e:
if "Expected AutoencoderKL or FluxAutoEncoder" in str(e):
context.logger.error("Decode VAE is incompatible with Z-Image latents; select the Flux/Z-Image VAE.")
else:
raise Prevention
- Never reuse SD/SDXL/SD3 VAE nodes in Z-Image graphs.
- Resolve all submodels (transformer, VAE, encoder) from one ZImageModelLoader output.
- Check the VAE's base in the Model Manager when a workflow is imported from elsewhere.
When it happens
Trigger: Running ZImageLatentsToImage with self.vae referencing a model whose class is neither AutoencoderKL nor FluxAutoEncoder, checked immediately after context.models.load(self.vae.vae).
Common situations: Using an SD/SDXL/SD3 VAE in a Z-Image workflow; graph templates reused across model families; VAE model misconfigured in the Model Manager; user manually pointing a decode node at a checkpoint's embedded wrong VAE.
Related errors
- Expected AutoencoderKL or FluxAutoEncoder, got {type(vae).__
- Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE,
- No VAE source provided. Either set 'VAE' to a FLUX VAE model
- Expected Qwen3Encoder_Checkpoint_Config, got {type(config)._
- Expected Qwen3Encoder_GGUF_Config, got {type(config).__name_
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/4f4b8cfa76d66f21.
Report an issue: GitHub.