Repository navigation
feat(auth): add auth=False for self-hosted servers without authentication - #833
Open
GregHolmes wants to merge 1 commit into
Open
GregHolmes wants to merge 1 commit into
GregHolmes wants to merge 1 commit into
Conversation
…tion Self-hosted and local Deepgram servers can run without request authentication, but the client could not be constructed without an API key, so there was no way to connect without inventing one. DeepgramClient and AsyncDeepgramClient now accept auth=False: no key is required, DEEPGRAM_API_KEY is ignored, and no Authorization header is sent on HTTP requests or WebSocket handshakes. It cannot be combined with api_key or access_token. When no key is available and the environment is not a Deepgram host, the missing-key error now suggests auth=False. The message for Deepgram's hosted API is unchanged apart from fixing "instantiated be either". Also documents the self-hosted setup in the README.
GregHolmes
requested review from
deepgram-kiley,
dg-coreylweathers and
jasondielman-dg
as code owners
November 19, 2026 17:24
Contributor
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Self-hosted and local Deepgram servers can run without request authentication. The Python client can't connect to one without inventing a key: constructing
DeepgramClientorAsyncDeepgramClientwith noapi_keyand noDEEPGRAM_API_KEYraises:This adds
auth=False, matching the JavaScript SDK'sauth: false:DEEPGRAM_API_KEYis ignored.Authorizationheader is sent on HTTP requests or WebSocket handshakes. It is removed with the sameclient_wrapper.get_headersoverride thataccess_tokenalready uses for Bearer auth, so every HTTP, async and WebSocket path is covered.auth=Falsecan't be combined withapi_keyoraccess_token(ValueError), andauthonly acceptsFalse.baseis notdeepgram.comor*.deepgram.com, the missing-key error ends with a hint to passauth=False. For Deepgram's hosted API the message is unchanged, apart from fixing the generated "instantiated be either" wording: the custom client now raises the missing-key error itself in both cases, as it already did for an explicitapi_key=None.All changes are in
src/deepgram/client.py(already frozen in.fernignore). The credential handling shared by the sync and async clients moved into a_resolve_credentialshelper, with the existingaccess_token, explicit-NoneandDEEPGRAM_API_KEYre-read behaviour kept as before.The README gains a "Self-Hosted and Local Servers Without Authentication" section under Authentication.
Types of changes
Checklist
Further comments
tests/custom/test_self_hosted_no_auth.py(added to.fernignore), 18 tests:DEEPGRAM_API_KEYignored underauth=False.Authorizationheader over HTTP (sync and async, viahttpx.MockTransport) and on the Listen v2 WebSocket handshake (sync and async).ValueErrorwhen combined withapi_keyoraccess_token, and for values other thanFalse.api_key=None, the async client, and a look-alike host (notdeepgram.com); the unchanged message for the default environment andapi.eu.deepgram.com.api_keyis still sent to a self-hosted environment.17 of the 18 fail without the change.
tests/customandtests/utilspass (1,132 tests) apart from two existing failures intest_core_utilities_coverage.pythat only occur on Windows (pathlib.Path("/x")encodes as\x) and fail the same way onmain.ruff check,ruff format --checkandmypyare clean.🤖 Generated with Claude Code