Skip to content

Commit a5276bb

Browse files
Merge pull request #284 from dvonthenen/fix-explicit-passing-api-key
Fix Explicitly Passing API Key to `DeepgramClient`
2 parents e2ddfb4 + ffd8828 commit a5276bb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: deepgram/client.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ def __init__(
158158
self.logger = logging.getLogger(__name__)
159159
self.logger.addHandler(logging.StreamHandler())
160160

161-
if config is not None:
161+
if api_key == "" and config is not None:
162+
self.logger.info("Attempting to set API key from config object")
162163
api_key = config.api_key
163-
if not api_key:
164-
# Default to `None` for on-prem instances where an API key is not required
165-
api_key = os.getenv("DEEPGRAM_API_KEY", None)
166-
if not api_key:
164+
if api_key == "":
165+
self.logger.info("Attempting to set API key from environment variable")
166+
api_key = os.getenv("DEEPGRAM_API_KEY", "")
167+
if api_key == "":
167168
self.logger.warning("WARNING: API key is missing")
168169

169170
self.api_key = api_key

0 commit comments

Comments
 (0)