invoke-ai/InvokeAI · error · ValueError

Unknown model: {key}

Error message

Unknown model: {key}

What it means

The FLUX model loader validates that the main transformer model and any selected companion models (T5 encoder, CLIP embed, VAE) exist in the model registry before loading. It raises ValueError('Unknown model: <key>') when context.models.exists(key) is false for any of them.

Source

Thrown at invokeai/app/invocations/flux_model_loader.py:91

        title="CLIP Embed",
        ui_model_type=ModelType.CLIPEmbed,
    )

    vae_model: ModelIdentifierField | None = InputField(
        default=None,
        description=FieldDescriptions.vae_model,
        title="VAE",
        ui_model_base=BaseModelType.Flux,
        ui_model_type=ModelType.VAE,
    )

    def invoke(self, context: InvocationContext) -> FluxModelLoaderOutput:
        keys = [self.model.key] + [
            m.key for m in (self.t5_encoder_model, self.clip_embed_model, self.vae_model) if m is not None
        ]
        for key in keys:
            if not context.models.exists(key):
                raise ValueError(f"Unknown model: {key}")

        main_config = context.models.get_config(self.model)
        self_contained = is_self_contained_sdnq_flux1_pipeline(main_config)

        def resolve(selected: ModelIdentifierField | None) -> ModelIdentifierField | None:
            """Explicit selection wins; otherwise the main model supplies the part if it can."""
            if selected is not None:
                return selected
            return self.model if self_contained else None

        t5_source = resolve(self.t5_encoder_model)
        clip_source = resolve(self.clip_embed_model)
        vae_source = resolve(self.vae_model)

        missing = [
            title
            for title, source in (("T5 Encoder", t5_source), ("CLIP Embed", clip_source), ("VAE", vae_source))
            if source is None

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Re-select the FLUX model (and companions) in the workflow so fresh valid keys are stored
  2. Install/scan the missing model via the Model Manager
  3. Remove optional companion selections that no longer exist if the main model supplies them
  4. Validate keys with context.models.exists() before running programmatically

Example fix

// before
model=ModelIdentifierField(key='flux-dev-deleted')
// after
model=ModelIdentifierField(key='<re-selected FLUX model key>')
Defensive patterns

Strategy: validation

Validate before calling

keys = [self.model.key] + [m.key for m in (t5, clip, vae) if m is not None]
missing = [k for k in keys if not context.models.exists(k)]
if missing:
    raise ValueError(f"Models missing from registry: {missing}")

Type guard

def all_models_exist(context, fields) -> bool:
    return all(context.models.exists(m.key) for m in fields if m is not None)

Try / catch

try:
    output = loader.invoke(context)
except ValueError as e:
    if str(e).startswith('Unknown model:'):
        bad_key = str(e).rsplit(':', 1)[1].strip()
        # re-select model with key bad_key
    else:
        raise

Prevention

When it happens

Trigger: invoke() builds keys from self.model plus optional t5_encoder_model/clip_embed_model/vae_model fields and any key is missing from the registry — deleted model, stale workflow reference, or invalid ModelIdentifierField.

Common situations: Model removed after the workflow was saved; workflow shared from another machine without the model installed; typo'd or hand-edited model key in a graph JSON.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/54be67f792971dbe. Report an issue: GitHub.