From 8911a14eaaa724e367df1a24901d146388be49cf Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 30 Sep 2025 15:38:42 +0200 Subject: [PATCH] Assign user_id if not present in key/generate If the user_id is not specified in the key/generate request it is not added automatically and doesn't appear in the dashboard. --- litellm/proxy/management_endpoints/key_management_endpoints.py | 3 +++ 1 file changed, 3 insertions(+) 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,