{"record":{"id":"2084dcf1f5269ad9","repo":"BerriAI/litellm","slug":"model-with-id-model-id-not-found","errorCode":null,"errorMessage":"Model with id={model_id} not found","messagePattern":"Model with id=(.+?) not found","errorType":"exception","errorClass":"NotFoundError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/client/models.py","lineNumber":204,"sourceCode":"        # Get all models and filter\n        models: Final = self.info()\n        assert isinstance(models, list)\n\n        # Find the matching model\n        for model in models:\n            if (model_id and model.get(\"model_info\", {}).get(\"id\") == model_id) or (\n                model_name and model.get(\"model_name\") == model_name\n            ):\n                return model\n\n        # If we get here, no model was found\n        if model_id:\n            msg = f\"Model with id={model_id} not found\"\n        elif model_name:\n            msg = f\"Model with model_name={model_name} not found\"\n        else:\n            msg = \"Unknown error trying to find model\"\n        raise NotFoundError(\n            requests.exceptions.HTTPError(\n                msg,\n                response=requests.Response(),  # Empty response since we didn't make a direct request\n            )\n        )\n\n    def info(self, return_request: bool = False) -> builtins.list[dict[str, Any]] | requests.Request:\n        \"\"\"\n        Get detailed information about all models from the server.\n\n        Args:\n            return_request (bool): If True, returns the prepared request object instead of executing it\n\n        Returns:\n            Union[List[Dict[str, Any]], requests.Request]: Either a list of model information dictionaries\n            or a prepared request object if return_request is True\n\n        Raises:","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/client/models.py#L186-L222","documentation":"Raised by ModelsManagementClient.get() after it fetched the full list from GET {base_url}/v1/model/info and found no entry whose model_info.id equals model_id or whose model_name equals model_name. It wraps a synthetic requests.exceptions.HTTPError carrying the message 'Model with id=... not found' / 'Model with model_name=... not found' and an empty requests.Response — no real HTTP 401/404 happened at this point; the miss is detected by local equality filtering, so casing and whitespace must match exactly.","triggerScenarios":"Requesting a model_name not deployed on this proxy (typos, wrong casing like 'GPT-4o' vs 'gpt-4o', environment-specific names); a stale model_id after config or database changes; input with surrounding whitespace; calling against the wrong base_url whose deployment lacks the model.","commonSituations":"Shared code across environments where model names differ; hardcoded names drifting from the deployed config; ids cached from a previous deployment; user-supplied names not trimmed.","solutions":["List what actually exists — [m.get('model_name') for m in models.info()] — and use an exact string from it","Normalize input before calling: model_name.strip() and match the proxy's casing","If the model should exist, check the proxy config/DB and confirm base_url points at the right deployment","Catch NotFoundError to degrade gracefully when optional models are absent"],"exampleFix":"# before\nclient.models.get(model_name=\"GPT-4O\")  # NotFoundError: Model with model_name=GPT-4O not found\n\n# after\nfrom litellm.proxy.client.exceptions import NotFoundError\ntry:\n    client.models.get(model_name=\"gpt-4o\")\nexcept NotFoundError:\n    available = [m.get(\"model_name\") for m in client.models.info()]\n    raise RuntimeError(f\"model not deployed; available: {available}\") from None","handlingStrategy":"try-catch","validationCode":"def find_model(models_client, model_id: str | None = None, model_name: str | None = None):\n    key, want = (\"id\", model_id) if model_id else (\"name\", model_name)\n    if want is not None:\n        want = want.strip()\n    for m in models_client.info():\n        if model_id and m.get(\"model_info\", {}).get(\"id\") == want:\n            return m\n        if model_name and m.get(\"model_name\") == want:\n            return m\n    return None  # resolve absence yourself instead of catching","typeGuard":null,"tryCatchPattern":"from litellm.proxy.client.exceptions import NotFoundError\n\ntry:\n    model = models.get(model_name=name.strip())\nexcept NotFoundError as e:\n    available = sorted(m.get(\"model_name\") for m in models.info())\n    raise RuntimeError(f\"{e} — deployed models: {available}\") from None","preventionTips":["Source names from models.info()/list() output rather than hardcoding, or validate against it first","Strip whitespace and match the proxy's exact casing — filtering is plain equality","Catch NotFoundError to branch when optional models are absent instead of crashing"],"tags":["litellm","not-found","python","models","client-side"],"backgroundTag":"resource-not-found","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}