From 3a9c82843709df635f0893b33abe5cf0cb3005b5 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Tue, 24 Oct 2023 10:57:45 -0700 Subject: [PATCH] (feat) openai proxy check AUTH_STRATEGY --- openai-proxy/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openai-proxy/main.py b/openai-proxy/main.py index 7d0937f67..1c36d1935 100644 --- a/openai-proxy/main.py +++ b/openai-proxy/main.py @@ -62,7 +62,8 @@ async def completion(request: Request): async def chat_completion(request: Request): try: data = await request.json() - if "authorization" in request.headers: # if users pass LLM api keys as part of header + # default to always using the "ENV" variables, only if AUTH_STRATEGY==DYNAMIC then reads headers + if os.getenv("AUTH_STRATEGY", None) == "DYNAMIC" and "authorization" in request.headers: # if users pass LLM api keys as part of header api_key = request.headers.get("authorization") api_key = api_key.replace("Bearer", "").strip() if len(api_key.strip()) > 0: