{"record":{"id":"67fa0034250cb271","repo":"Stability-AI/generative-models","slug":"model-model-id-not-supported","errorCode":null,"errorMessage":"Model {model_id} not supported","messagePattern":"Model (.+?) not supported","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sgm/inference/api.py","lineNumber":143,"sourceCode":"        is_legacy=True,\r\n        config=\"sd_xl_refiner.yaml\",\r\n        ckpt=\"sd_xl_refiner_1.0.safetensors\",\r\n        is_guided=True,\r\n    ),\r\n}\r\n\r\n\r\nclass SamplingPipeline:\r\n    def __init__(\r\n        self,\r\n        model_id: ModelArchitecture,\r\n        model_path=\"checkpoints\",\r\n        config_path=\"configs/inference\",\r\n        device=\"cuda\",\r\n        use_fp16=True,\r\n    ) -> None:\r\n        if model_id not in model_specs:\r\n            raise ValueError(f\"Model {model_id} not supported\")\r\n        self.model_id = model_id\r\n        self.specs = model_specs[self.model_id]\r\n        self.config = str(pathlib.Path(config_path, self.specs.config))\r\n        self.ckpt = str(pathlib.Path(model_path, self.specs.ckpt))\r\n        self.device = device\r\n        self.model = self._load_model(device=device, use_fp16=use_fp16)\r\n\r\n    def _load_model(self, device=\"cuda\", use_fp16=True):\r\n        config = OmegaConf.load(self.config)\r\n        model = load_model_from_config(config, self.ckpt)\r\n        if model is None:\r\n            raise ValueError(f\"Model {self.model_id} could not be loaded\")\r\n        model.to(device)\r\n        if use_fp16:\r\n            model.conditioner.half()\r\n            model.model.half()\r\n        return model\r\n\r","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/Stability-AI/generative-models/blob/e8cd657656fa5d61688191730d0e03242bf4ed44/sgm/inference/api.py#L125-L161","documentation":"sgm.inference.api.SGMWrapper (its __init__) only supports the fixed set of model IDs hard-coded in the module-level `model_specs` dict. Passing any other string raises this ValueError before any file I/O happens, so it is purely a name-validation failure against the supported model registry.","triggerScenarios":"Constructing `SGMWrapper(model_id=\"sd-2.1\")` (or any typo) where model_id is not a key of `model_specs` in sgm/inference/api.py — e.g. misspelled names like \"stable-diffusion-2.1\" instead of the exact registered ID, or inventing an ID for a checkpoint the wrapper was never configured for.","commonSituations":"Copying code from blog posts referencing different model naming conventions; upgrading the library where supported IDs changed; assuming arbitrary fine-tuned checkpoints can be loaded by making up an ID.","solutions":["Inspect `sgm.inference.api.model_specs.keys()` and pass one of the exact registered model_id strings.","Fix the typo so model_id matches a supported key exactly (case and spelling).","If your model genuinely is unsupported, add a ModelSpec entry to model_specs with its config and checkpoint, or use a loader like load_model_from_config directly."],"exampleFix":"// before\nmodel = SGMWrapper(model_id=\"stable-diffusion-xl\")\n// after\nfrom sgm.inference.api import model_specs, SGMWrapper\nprint(model_specs.keys())\nmodel = SGMWrapper(model_id=\"sd-template-2.2\")  # must be a key in model_specs","handlingStrategy":"validation","validationCode":"from sgm.inference.api import model_specs\nassert model_id in model_specs, f\"model_id must be one of {list(model_specs)}\"","typeGuard":"from typing import Literal, get_args\nModelId = Literal[tuple(model_specs.keys())]\ndef is_valid_model_id(x: str) -> bool:\n    return x in model_specs","tryCatchPattern":"try:\n    model = SGMWrapper(model_id=model_id)\nexcept ValueError as e:\n    print(f\"Bad model_id: {e}; supported: {list(model_specs.keys())}\")","preventionTips":["Copy model_id strings from model_specs.keys(), never from memory or blog posts.","Wrap the id in a Literal/enum type in your own code."],"tags":["configuration","api-misuse","model-registry"],"backgroundTag":"unsupported-model","analyzedSha":"e8cd657656fa5d61688191730d0e03242bf4ed44","analyzedAt":"2026-08-29T11:23:43.234Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}