{"record":{"id":"70040f5c65a9f011","repo":"BerriAI/litellm","slug":"can-t-edit-model-model-in-config-store-model-in","errorCode":null,"errorMessage":"Can't edit model. Model in config. Store model in db via `/model/new`. to edit.","messagePattern":"Can't edit model\\. Model in config\\. Store model in db via `/model/new`\\. to edit\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/management_endpoints/model_management_endpoints.py","lineNumber":1929,"sourceCode":"                detail={\n                    \"error\": \"No DB Connected. Here's how to do it - https://docs.litellm.ai/docs/proxy/virtual_keys\"\n                },\n            )\n\n        _model_id: str | None = None\n        _model_info: Final = getattr(model_params, \"model_info\", None)\n        if _model_info is None:\n            raise Exception(\"model_info not provided\")\n\n        _model_id = _model_info.id\n        if _model_id is None:\n            raise Exception(\"model_info.id not provided\")\n\n        _existing_litellm_params = await ModelRepository(prisma_client).table.find_unique(where={\"model_id\": _model_id})\n\n        if _existing_litellm_params is None:\n            if llm_router is not None and llm_router.get_deployment(model_id=_model_id) is not None:\n                raise HTTPException(\n                    status_code=400,\n                    detail={\"error\": \"Can't edit model. Model in config. Store model in db via `/model/new`. to edit.\"},\n                )\n            else:\n                raise Exception(\"model not found\")\n        deployment: Final = Deployment(**_existing_litellm_params.model_dump())\n\n        await ModelManagementAuthChecks.can_user_make_model_call(\n            model_params=deployment,\n            user_api_key_dict=user_api_key_dict,\n            prisma_client=prisma_client,\n            premium_user=premium_user,\n        )\n\n        _raise_on_strategy_router_write_violation(\n            incoming_params=model_params.litellm_params,\n            existing_params=deployment.litellm_params,\n        )","sourceCodeStart":1911,"sourceCodeEnd":1947,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/model_management_endpoints.py#L1911-L1947","documentation":"Source-of-truth guard on model update: the model_id exists in the live router but has no DB row, meaning it was defined in config.yaml. Config-defined models are immutable via the API — they must be edited in config and reloaded, or migrated to the DB via /model/new.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:1929 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Store the model in the database via /model/new first; config-file models cannot be edited via this endpoint."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}