diff --git a/litellm/proxy/auth/handle_jwt.py b/litellm/proxy/auth/handle_jwt.py index 4689ffe7bf12..35b884b58919 100644 --- a/litellm/proxy/auth/handle_jwt.py +++ b/litellm/proxy/auth/handle_jwt.py @@ -114,7 +114,8 @@ async def get_public_key(self, kid: Optional[str]) -> dict: public_key: Optional[dict] = None if len(keys) == 1: - public_key = keys[0] + if kid is None or key["kid"] == kid: + public_key = keys[0] elif len(keys) > 1: for key in keys: if kid is not None and key["kid"] == kid: