From 5847037b3a138dbfc74eff7199d53804418ceb3e Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 4 Sep 2025 14:40:28 -0700 Subject: [PATCH] Add validation for STORE_MODEL_IN_DB when updating public model groups (#14269) Co-authored-by: Cursor Agent Co-authored-by: ishaan --- .../model_management_endpoints.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/model_management_endpoints.py b/litellm/proxy/management_endpoints/model_management_endpoints.py index b8762899f1..2e1a684e39 100644 --- a/litellm/proxy/management_endpoints/model_management_endpoints.py +++ b/litellm/proxy/management_endpoints/model_management_endpoints.py @@ -987,7 +987,7 @@ async def update_public_model_groups( try: # Update the public model groups import litellm - from litellm.proxy.proxy_server import proxy_config + from litellm.proxy.proxy_server import proxy_config, store_model_in_db # Check if user has admin permissions if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN: @@ -1000,6 +1000,15 @@ async def update_public_model_groups( }, ) + # Check if STORE_MODEL_IN_DB is enabled + if store_model_in_db is not True: + raise HTTPException( + status_code=500, + detail={ + "error": "Set `'STORE_MODEL_IN_DB='True'` in your env to enable this feature." + }, + ) + litellm.public_model_groups = request.model_groups # Load existing config