From d76a09681f40f079b4fe779eba5593776de9fc8b Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 12 Jul 2024 18:41:39 -0700 Subject: [PATCH] raise roxyErrorTypes.expired_key on expired key --- litellm/proxy/auth/user_api_key_auth.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/auth/user_api_key_auth.py b/litellm/proxy/auth/user_api_key_auth.py index 4b931a2726..d02ebe4ceb 100644 --- a/litellm/proxy/auth/user_api_key_auth.py +++ b/litellm/proxy/auth/user_api_key_auth.py @@ -753,9 +753,11 @@ async def user_api_key_auth( ) if expiry_time < current_time: # Token exists but is expired. - raise HTTPException( - status_code=status.HTTP_403_FORBIDDEN, - detail=f"Authentication Error - Expired Key. Key Expiry time {expiry_time} and current time {current_time}", + raise ProxyException( + message=f"Authentication Error - Expired Key. Key Expiry time {expiry_time} and current time {current_time}", + type=ProxyErrorTypes.expired_key, + code=400, + param=api_key, ) # Check 4. Token Spend is under budget