{"record":{"id":"7aedf0784551de3d","repo":"mudler/LocalAI","slug":"model-id-is-required-to-load-a-pipeline","errorCode":null,"errorMessage":"model_id is required to load a pipeline","messagePattern":"model_id is required to load a pipeline","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/diffusers/diffusers_dynamic_loader.py","lineNumber":480,"sourceCode":"\n        # Load from single file\n        pipe = load_diffusers_pipeline(\n            class_name=\"StableDiffusionPipeline\",\n            model_id=\"/path/to/model.safetensors\",\n            from_single_file=True,\n            torch_dtype=torch.float16\n        )\n    \"\"\"\n    # Resolve the pipeline class\n    pipeline_class = resolve_pipeline_class(\n        class_name=class_name,\n        task=task,\n        model_id=model_id\n    )\n\n    # If no model_id provided but we have a class, we can't load\n    if model_id is None:\n        raise ValueError(\"model_id is required to load a pipeline\")\n\n    # Load the pipeline\n    try:\n        if from_single_file:\n            # Check if the class has from_single_file method\n            if hasattr(pipeline_class, 'from_single_file'):\n                return pipeline_class.from_single_file(model_id, **kwargs)\n            else:\n                raise ValueError(\n                    f\"Pipeline class {pipeline_class.__name__} does not support from_single_file(). \"\n                    f\"Use from_pretrained() instead.\"\n                )\n        else:\n            return pipeline_class.from_pretrained(model_id, **kwargs)\n\n    except Exception as e:\n        # Provide helpful error message\n        available = get_available_pipelines()","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/diffusers/diffusers_dynamic_loader.py#L462-L498","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass model_id pointing at a local snapshot path or HuggingFace repo id.","Check the backend request's model field is populated before invoking the loader.","If you only wanted registry info (not a loaded pipeline), call get_pipeline_info(class_name) instead."],"exampleFix":"# before\npipe = load_diffusers_pipeline(class_name=\"StableDiffusionXLPipeline\")\n\n# after\npipe = load_diffusers_pipeline(class_name=\"StableDiffusionXLPipeline\", model_id=\"/models/sdxl\")","handlingStrategy":"validation","validationCode":"assert model_id, \"model_id is required to instantiate a diffusers pipeline\"","typeGuard":"def can_load_pipeline(model_id) -> bool:\n    return model_id is not None and str(model_id).strip() != \"\"","tryCatchPattern":"try:\n    pipe = load_diffusers_pipeline(class_name=c, model_id=model_id)\nexcept ValueError as e:\n    if \"model_id is required\" in str(e):\n        return error_reply(\"no model configured for this request\")\n    raise","preventionTips":["Always resolve the model reference before calling the loader.","Default model_id from the request's model field in your wrapper.","Use get_pipeline_info() when you only need metadata and have no weights."],"tags":["diffusers","argument-validation","model-loading","programming-error"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}