diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index 007c0164be4..5a17e475f9f 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -580,6 +580,9 @@ async def _common_key_generation_helper( # noqa: PLR0915 prisma_client=prisma_client, ) + if data_json.get("user_id", None) is None: + data_json["user_id"] = user_api_key_dict.user_id + await _enforce_unique_key_alias( key_alias=data_json.get("key_alias", None), prisma_client=prisma_client,