From e61d8c7255e33992e137392a7ee1b8695b62cda7 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Mon, 23 Oct 2023 10:55:28 -0700 Subject: [PATCH] (fix) make setting keys in header optional --- openai-proxy/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openai-proxy/main.py b/openai-proxy/main.py index f690330a6..f51c4b56f 100644 --- a/openai-proxy/main.py +++ b/openai-proxy/main.py @@ -60,10 +60,10 @@ async def completion(request: Request): async def chat_completion(request: Request): try: data = await request.json() - - api_key = request.headers.get("authorization") - api_key = api_key.split(" ")[1] - data["api_key"] = api_key + if "authorization" in request.headers: # if users pass LLM api keys as part of header + api_key = request.headers.get("authorization") + api_key = api_key.split(" ")[1] + data["api_key"] = api_key response = litellm.completion( **data )