Skip to content

Skip the network probe in DeepgramProvider.health_check when the API key is missing #168

Description

@mahimairaja

Want to work on this? Comment .take and it is yours (first comment wins). When your fix is ready, open a PR with Closes #168.


Good first issue. One guard line, to match four other providers.

What's going on

When you check a provider's health with no API key set, most cloud providers short-circuit and return False right away without hitting the network. Deepgram does not. With no key, DeepgramProvider.health_check still fires a live request to https://api.deepgram.com/v1/projects with the header Authorization: Token None. It does not crash (the whole body is wrapped in try/except Exception: return False), but the request is pointless: no key means it can never pass, so we should skip the round-trip.

Cartesia, Anthropic, ElevenLabs, and AssemblyAI already do the right thing. This issue makes Deepgram match them.

What to do

One file: src/voicegateway/inference/providers/deepgram_provider.py (the health_check method starts at line 44).

Copy the pattern from src/voicegateway/inference/providers/cartesia_provider.py (lines 45-46). Add an early return before the try:

    async def health_check(self) -> bool:
        import httpx

        if not self.api_key:
            return False
        try:
            async with httpx.AsyncClient() as client:
                ...

That is the entire change. self.api_key is already set in __init__ (line 13), so no other edits are needed.

How to test

There is already a test for this exact pattern on Cartesia. Copy it for Deepgram.

  1. Look at src/voicegateway/tests/providers/test_cartesia_health_check.py, specifically test_health_check_returns_false_when_key_missing (lines 48-55). It patches httpx.AsyncClient to blow up if called, then asserts health_check() returns False without ever touching the network.
  2. Add the same test for DeepgramProvider (a new file src/voicegateway/tests/providers/test_deepgram_health_check.py, or add a case next to the existing Deepgram tests). Remember to monkeypatch.delenv("DEEPGRAM_API_KEY", raising=False) so an env var does not leak in.
  3. Run it:
pytest src/voicegateway/tests/providers/test_deepgram_health_check.py

Bonus (optional)

openai_provider.py (line 58) and groq_provider.py (line 48) also probe without this guard. If you want, add the same if not self.api_key: return False line to each in the same PR so all cloud providers behave consistently.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions