mudler/LocalAI · error · ValueError

model_id is required to load a pipeline

Error message

model_id is required to load a pipeline

What it means

Raised by load_diffusers_pipeline after pipeline class resolution succeeded but model_id is None. A class alone cannot be instantiated — diffusers pipelines need model weights — so the loader refuses early with a clear message instead of passing None into from_pretrained.

Source

Thrown at backend/python/diffusers/diffusers_dynamic_loader.py:480

        # Load from single file
        pipe = load_diffusers_pipeline(
            class_name="StableDiffusionPipeline",
            model_id="/path/to/model.safetensors",
            from_single_file=True,
            torch_dtype=torch.float16
        )
    """
    # Resolve the pipeline class
    pipeline_class = resolve_pipeline_class(
        class_name=class_name,
        task=task,
        model_id=model_id
    )

    # If no model_id provided but we have a class, we can't load
    if model_id is None:
        raise ValueError("model_id is required to load a pipeline")

    # Load the pipeline
    try:
        if from_single_file:
            # Check if the class has from_single_file method
            if hasattr(pipeline_class, 'from_single_file'):
                return pipeline_class.from_single_file(model_id, **kwargs)
            else:
                raise ValueError(
                    f"Pipeline class {pipeline_class.__name__} does not support from_single_file(). "
                    f"Use from_pretrained() instead."
                )
        else:
            return pipeline_class.from_pretrained(model_id, **kwargs)

    except Exception as e:
        # Provide helpful error message
        available = get_available_pipelines()

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Pass model_id pointing at a local snapshot path or HuggingFace repo id.
  2. Check the backend request's model field is populated before invoking the loader.
  3. If you only wanted registry info (not a loaded pipeline), call get_pipeline_info(class_name) instead.

Example fix

# before
pipe = load_diffusers_pipeline(class_name="StableDiffusionXLPipeline")

# after
pipe = load_diffusers_pipeline(class_name="StableDiffusionXLPipeline", model_id="/models/sdxl")
Defensive patterns

Strategy: validation

Validate before calling

assert model_id, "model_id is required to instantiate a diffusers pipeline"

Type guard

def can_load_pipeline(model_id) -> bool:
    return model_id is not None and str(model_id).strip() != ""

Try / catch

try:
    pipe = load_diffusers_pipeline(class_name=c, model_id=model_id)
except ValueError as e:
    if "model_id is required" in str(e):
        return error_reply("no model configured for this request")
    raise

Prevention

When it happens

Trigger: Calling load_diffusers_pipeline(class_name='StableDiffusionPipeline') or (task='text-to-image') without a model_id; resolution steps 1/2 succeed, then the guard trips.

Common situations: Caller assumes the class has bundled default weights (it does not), a wrapper that resolves the class first and forgets to forward the model path, or an empty Model field in the backend request.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/7aedf0784551de3d. Report an issue: GitHub.