From 3c7210b148a6a3ae459f2b2b78db26196a41108d Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 19 May 2025 20:59:22 -0700 Subject: [PATCH] fix: router management endpoints --- .../router_management_endpoints.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/management_endpoints/router_management_endpoints.py b/litellm/proxy/management_endpoints/router_management_endpoints.py index fd1bfd86388..3f32b0236ec 100644 --- a/litellm/proxy/management_endpoints/router_management_endpoints.py +++ b/litellm/proxy/management_endpoints/router_management_endpoints.py @@ -1,5 +1,6 @@ import asyncio import copy +from typing import Dict, Union from fastapi import APIRouter, Depends, HTTPException, status @@ -64,12 +65,16 @@ async def update_router_settings( detail={"error": "Only proxy admin users can update router settings"}, ) - existing_router_settings = ( - await prisma_client.db.litellm_config.find_unique( - where={"param_name": "router_settings"} - ) - or {} + router_settings_row = await prisma_client.db.litellm_config.find_unique( + where={"param_name": "router_settings"} ) + existing_router_settings: dict = {} + if router_settings_row: + param_value: Union[Dict, str] = router_settings_row.param_value + if isinstance(param_value, str): + existing_router_settings = safe_json_loads(data=param_value) + elif isinstance(param_value, dict): + existing_router_settings = param_value # new router settings new_router_settings: dict = copy.deepcopy(dict(existing_router_settings)) @@ -86,6 +91,7 @@ async def update_router_settings( "param_value": safe_dumps(new_router_settings), }, "update": { + "param_name": "router_settings", "param_value": safe_dumps(new_router_settings), }, },