BerriAI/litellm · error · HTTPException

Failed to add model to db. Check your server logs for more…

Error message

Failed to add model to db. Check your server logs for more details.

What it means

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.

Solutions

  1. Check proxy server logs for the underlying database error.
  2. Verify DATABASE_URL connectivity and schema migrations are applied.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:1833 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/45d90791b7c4de28. Report an issue: GitHub.

Appendix: source

Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:1833

                _alerting: Final = general_settings.get("alerting", []) or []
                if "slack" in _alerting:
                    # send notification - new model added
                    await proxy_logging_obj.slack_alerting_instance.model_added_alert(
                        model_name=priced_model_params.model_name,
                        litellm_model_name=_original_litellm_model_name,
                        passed_model_info=priced_model_params.model_info,
                    )
            except Exception as e:
                verbose_proxy_logger.exception("Exception in add_new_model: %s", e)

        else:
            raise HTTPException(
                status_code=500,
                detail={"error": "Set `'STORE_MODEL_IN_DB='True'` in your env to enable this feature."},
            )

        if model_response is None:
            raise HTTPException(
                status_code=500,
                detail={"error": "Failed to add model to db. Check your server logs for more details."},
            )

        ## CREATE AUDIT LOG ##
        asyncio.create_task(
            create_object_audit_log(
                object_id=model_response.model_id,
                action="created",
                user_api_key_dict=user_api_key_dict,
                table_name=LitellmTableNames.PROXY_MODEL_TABLE_NAME,
                before_value=None,
                after_value=(
                    model_response.model_dump_json(exclude_none=True) if isinstance(model_response, BaseModel) else None
                ),
                litellm_changed_by=user_api_key_dict.user_id,
                litellm_proxy_admin_name=LITELLM_PROXY_ADMIN_NAME,
            )

View on GitHub (pinned to 77b7c6c40c)