{"record":{"id":"45d90791b7c4de28","repo":"BerriAI/litellm","slug":"failed-to-add-model-to-db-check-your-server-logs","errorCode":null,"errorMessage":"Failed to add model to db. Check your server logs for more details.","messagePattern":"Failed to add model to db\\. Check your server logs for more details\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_endpoints/model_management_endpoints.py","lineNumber":1833,"sourceCode":"                _alerting: Final = general_settings.get(\"alerting\", []) or []\n                if \"slack\" in _alerting:\n                    # send notification - new model added\n                    await proxy_logging_obj.slack_alerting_instance.model_added_alert(\n                        model_name=priced_model_params.model_name,\n                        litellm_model_name=_original_litellm_model_name,\n                        passed_model_info=priced_model_params.model_info,\n                    )\n            except Exception as e:\n                verbose_proxy_logger.exception(\"Exception in add_new_model: %s\", e)\n\n        else:\n            raise HTTPException(\n                status_code=500,\n                detail={\"error\": \"Set `'STORE_MODEL_IN_DB='True'` in your env to enable this feature.\"},\n            )\n\n        if model_response is None:\n            raise HTTPException(\n                status_code=500,\n                detail={\"error\": \"Failed to add model to db. Check your server logs for more details.\"},\n            )\n\n        ## CREATE AUDIT LOG ##\n        asyncio.create_task(\n            create_object_audit_log(\n                object_id=model_response.model_id,\n                action=\"created\",\n                user_api_key_dict=user_api_key_dict,\n                table_name=LitellmTableNames.PROXY_MODEL_TABLE_NAME,\n                before_value=None,\n                after_value=(\n                    model_response.model_dump_json(exclude_none=True) if isinstance(model_response, BaseModel) else None\n                ),\n                litellm_changed_by=user_api_key_dict.user_id,\n                litellm_proxy_admin_name=LITELLM_PROXY_ADMIN_NAME,\n            )","sourceCodeStart":1815,"sourceCodeEnd":1851,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/model_management_endpoints.py#L1815-L1851","documentation":"Catch-all in the model-add flow: after validation, pricing, and Slack alerting, any unexpected exception persisting the new model is logged ('Exception in add_model...' in server logs) and surfaced as this generic 500 — the request itself may be valid, the failure is on the write/reload side.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:1833 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check proxy server logs for the underlying database error.","Verify DATABASE_URL connectivity and schema migrations are applied."],"exampleFix":null,"handlingStrategy":"try-catch","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-14T11:17:12.474Z"}