invoke-ai/InvokeAI · error · TypeError
Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE,
Error message
Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE, got {type(vae_info.model).__name__}. What it means
The Anima VAE encode entry point only supports AutoencoderKLWan or FluxAutoEncoder VAE models. Before doing any work, vae_encode type-checks the loaded model and raises this TypeError if the model manager returned some other VAE class.
Source
Thrown at invokeai/app/invocations/anima_image_to_latents.py:61
@invocation(
"anima_i2l",
title="Image to Latents - Anima",
tags=["image", "latents", "vae", "i2l", "anima"],
category="image",
version="1.0.1",
classification=Classification.Prototype,
)
class AnimaImageToLatentsInvocation(BaseInvocation, WithMetadata, WithBoard):
"""Generates latents from an image using the Anima VAE (supports Wan 2.1 and FLUX VAE)."""
image: ImageField = InputField(description="The image to encode.")
vae: VAEField = InputField(description=FieldDescriptions.vae, input=Input.Connection)
@staticmethod
def vae_encode(vae_info: LoadedModel, image_tensor: torch.Tensor) -> torch.Tensor:
if not isinstance(vae_info.model, (AutoencoderKLWan, FluxAutoEncoder)):
raise TypeError(
f"Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE, got {type(vae_info.model).__name__}."
)
if isinstance(vae_info.model, AutoencoderKLWan):
estimated_working_memory = estimate_vae_working_memory_anima(
operation="encode",
image_tensor=image_tensor,
vae=vae_info.model,
tile_size=None,
)
else:
estimated_working_memory = estimate_vae_working_memory_flux(
operation="encode",
image_tensor=image_tensor,
vae=vae_info.model,
)
with vae_info.model_on_device(working_mem_bytes=estimated_working_memory) as (_, vae):View on GitHub (pinned to 0b6a024f2f)
Solutions
- Select an Anima-compatible VAE (AutoencoderKLWan or FluxAutoEncoder) in the VAE loader node.
- Verify the VAE model's base/architecture matches Anima in the model manager.
- Re-import the VAE if the model manager resolved the wrong class for its key.
Example fix
// before vae = vae_loader(vae_model="sdxl-vae") // after vae = vae_loader(vae_model="anima-vae") # AutoencoderKLWan / FluxAutoEncoder
Defensive patterns
Strategy: type-guard
Validate before calling
vae_info = context.models.load(vae.vae) from diffusers import AutoencoderKLWan from invokeai.backend.flux.model import FluxAutoEncoder assert isinstance(vae_info.model, (AutoencoderKLWan, FluxAutoEncoder)), "incompatible VAE"
Type guard
def is_anima_vae(model) -> bool:
from diffusers import AutoencoderKLWan
from invokeai.backend.flux.model import FluxAutoEncoder
return isinstance(model, (AutoencoderKLWan, FluxAutoEncoder)) Try / catch
try:
latents = img2latents.invoke(context)
except TypeError as e:
if "Anima VAE" in str(e):
raise RuntimeError("Attach an Anima-compatible VAE loader") from e Prevention
- Match VAE base model to the pipeline family before wiring workflows
- Check the model type column in the model manager UI
- Avoid reusing SD/SDXL VAE fields in Anima workflows
When it happens
Trigger: Connecting a VAE field whose loaded model is e.g. AutoencoderKL (SD/SDXL VAE) or another unsupported class to the Anima ImageToLatents node's vae input.
Common situations: Selecting a mismatched VAE in a workflow (SDXL VAE with an Anima pipeline); a model-manager lookup returning the wrong model due to duplicate keys; workflows copied across pipelines with different model families.
Related errors
- Expected AutoencoderKL or FluxAutoEncoder, got {type(vae).__
- Expected ModelPatchRaw for LoRA '{lora.lora.key}', got {type
- Expected AutoencoderKLWan or FluxAutoEncoder, got {type(vae)
- Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE,
- Expected AutoencoderKLWan or FluxAutoEncoder, got {type(vae)
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/7641f971452e876f.
Report an issue: GitHub.