From ffd8828dff7fb7a32ca5457da1ffba1db3633b8b Mon Sep 17 00:00:00 2001 From: David vonThenen <12752197+dvonthenen@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:16:33 -0800 Subject: [PATCH] Fix Explicitly Passing API Key to `DeepgramClient` --- deepgram/client.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/deepgram/client.py b/deepgram/client.py index 9f7fac24..19137443 100644 --- a/deepgram/client.py +++ b/deepgram/client.py @@ -158,12 +158,13 @@ def __init__( self.logger = logging.getLogger(__name__) self.logger.addHandler(logging.StreamHandler()) - if config is not None: + if api_key == "" and config is not None: + self.logger.info("Attempting to set API key from config object") api_key = config.api_key - if not api_key: - # Default to `None` for on-prem instances where an API key is not required - api_key = os.getenv("DEEPGRAM_API_KEY", None) - if not api_key: + if api_key == "": + self.logger.info("Attempting to set API key from environment variable") + api_key = os.getenv("DEEPGRAM_API_KEY", "") + if api_key == "": self.logger.warning("WARNING: API key is missing") self.api_key = api_key