From bfaed56ffb0a595c8d1354439acc5479fd8af22e Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 23 Nov 2023 16:45:44 -0800 Subject: [PATCH] fix(main.py): only set api key to dynamic api key if it's not none --- litellm/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/main.py b/litellm/main.py index d096c5b7d8..1e8191e363 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -371,7 +371,7 @@ def completion( if deployment_id != None: # azure llms model=deployment_id custom_llm_provider="azure" - model, custom_llm_provider, api_key, api_base = get_llm_provider(model=model, custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key) + model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(model=model, custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key) custom_prompt_dict = {} # type: ignore if initial_prompt_value or roles or final_prompt_value or bos_token or eos_token: custom_prompt_dict = {model: {}} @@ -391,6 +391,8 @@ def completion( custom_llm_provider = "openai" api_key = model_api_key + if dynamic_api_key is not None: + api_key = dynamic_api_key # check if user passed in any of the OpenAI optional params optional_params = get_optional_params( functions=functions,