From 2615edc468042333fbe9965e88fb06113fd77d03 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 26 Aug 2024 18:15:52 -0700 Subject: [PATCH] allow using hashed api keys on regen key --- .../proxy/management_endpoints/key_management_endpoints.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index ebe1d9db3bb..aef2fb39304 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -1008,7 +1008,11 @@ async def regenerate_key_fn( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail={"error": "DB not connected. prisma_client is None"}, ) - hashed_api_key = hash_token(key) + + if "sk" not in key: + hashed_api_key = key + else: + hashed_api_key = hash_token(key) _key_in_db = await prisma_client.db.litellm_verificationtoken.find_unique( where={"token": hashed_api_key},