Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix API Key Being Logged (#12978)

aayush-malviya-acquia1e315dc33b13
diff --git a/litellm/proxy/auth/user_api_key_auth.py b/litellm/proxy/auth/user_api_key_auth.py
index fb70426bd52..31395fe7da0 100644
--- a/litellm/proxy/auth/user_api_key_auth.py
+++ b/litellm/proxy/auth/user_api_key_auth.py
@@ -579,7 +579,7 @@ async def _user_api_key_auth_builder( # noqa: PLR0915
elif api_key == "":
# missing 'Bearer ' prefix
raise Exception(
- f"Malformed API Key passed in. Ensure Key has `Bearer ` prefix. Passed in: {passed_in_key}"
+ "Malformed API Key passed in. Ensure Key has `Bearer ` prefix."
)
if route == "/user/auth":
@@ -1237,7 +1237,7 @@ def get_api_key_from_custom_header(
api_key = _get_bearer_token(api_key=custom_api_key)
verbose_proxy_logger.debug(
"Found custom API key using header: {}, setting api_key={}".format(
- custom_litellm_key_header_name, api_key
+ custom_litellm_key_header_name, abbreviate_api_key(api_key)
)
)
else: