Skip to content

[Example] 530 — Multi-Provider Chat Completions Proxy for Voice Agent (Python)#210

Open
github-actions[bot] wants to merge 3 commits intomainfrom
example/530-voice-agent-multi-provider-proxy-python
Open

[Example] 530 — Multi-Provider Chat Completions Proxy for Voice Agent (Python)#210
github-actions[bot] wants to merge 3 commits intomainfrom
example/530-voice-agent-multi-provider-proxy-python

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 8, 2026

New example: Multi-Provider Chat Completions Proxy for Voice Agent

Integration: Deepgram Voice Agent API | Language: Python | Products: agent

What this shows

A FastAPI proxy server that exposes an OpenAI-compatible /v1/chat/completions endpoint, routing requests to multiple LLM backends (OpenAI, AWS Bedrock). The Deepgram Voice Agent API uses this proxy via think.endpoint.url, letting developers swap LLM providers without changing application code.

The demo script connects a Deepgram Voice Agent to the proxy, demonstrating how STT (nova-3) and TTS (aura-2) run natively on Deepgram while LLM reasoning routes through a configurable backend.

Required secrets

  • DEEPGRAM_API_KEY — Deepgram console
  • OPENAI_API_KEY — OpenAI dashboard
  • AWS credentials (optional, for Bedrock provider): AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION

Tests

✅ Tests passed (8/8)

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED

Built by Engineer on 2026-04-08

@github-actions github-actions bot force-pushed the example/530-voice-agent-multi-provider-proxy-python branch from 21dba4e to ba37b26 Compare April 8, 2026 09:01
@github-actions github-actions bot changed the title [Example] 530 — Voice Agent Multi-Provider Chat Completions Proxy (Python) [Example] 530 — Multi-Provider Chat Completions Proxy for Voice Agent (Python) Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 8, 2026

Code Review

Overall: CHANGES REQUESTED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED                       [ 12%]
tests/test_example.py::test_models_endpoint PASSED                       [ 25%]
tests/test_example.py::test_chat_completions_missing_messages PASSED     [ 37%]
tests/test_example.py::test_chat_completions_invalid_provider PASSED     [ 50%]
tests/test_example.py::test_chat_completions_openai PASSED               [ 62%]
tests/test_example.py::test_provider_header_override PASSED              [ 75%]
tests/test_example.py::test_voice_agent_settings_builder PASSED          [ 87%]
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED [100%]

8 passed in 3.76s

All 8 tests pass — proxy routes to OpenAI successfully and Voice Agent accepts custom endpoint settings via real WebSocket connection.

Integration genuineness

❌ FAIL — NO RAW PROTOCOL CHECK (check 6)

demo_agent.py uses websockets.sync.client.connect() directly to wss://agent.deepgram.com/v1/agent/converse instead of the Deepgram Python SDK's agent.v1.connect method. The test (test_voice_agent_accepts_custom_endpoint_settings) does the same.

The deepgram-sdk==6.1.1 is listed in requirements.txt but is never imported in any source file. The SDK has full Voice Agent support via DeepgramClient.agent.v1.connect() — this should be used instead of raw WebSocket connections.

Other checks pass:

  • ✅ Platform SDK is in requirements (deepgram-sdk==6.1.1, correct version)
  • ✅ Real API calls to OpenAI and Deepgram Voice Agent (not mocked)
  • .env.example lists both DEEPGRAM_API_KEY and OPENAI_API_KEY
  • ✅ Tests exit(2) on missing credentials
  • ✅ BYPASS CHECK: N/A — this is a proxy example; no partner audio SDK to route through

Code quality

Issues found:

  1. Raw WebSocket instead of SDKdemo_agent.py and the integration test use websockets library directly. Must use deepgram-sdk's agent client.
  2. Missing tags: ["deepgram-examples"] — Voice Agent Settings messages don't include the required tag. (Fixed locally: added to build_settings() in demo_agent.py and to the test's Settings dict.)
  3. Unused json import in providers.py line 10. (Fixed locally: removed.)
  4. Unused dependencydeepgram-sdk==6.1.1 is in requirements.txt but never imported anywhere in src/.
  5. __pycache__ not gitignored — no .gitignore in the example directory.

What's good:

  • ✅ No hardcoded credentials — all from env vars
  • ✅ Good error handling (missing messages, invalid provider, provider errors)
  • ✅ Tests import from src/ and test the actual proxy endpoints
  • ✅ Server test spins up via TestClient and makes real HTTP requests
  • ✅ No word-list assertions — only structural checks on responses
  • ✅ Credential check runs first before imports
  • ✅ SDK version is correct (deepgram-sdk==6.1.1)

Documentation

  • ✅ README covers what you'll build, all env vars with links, run instructions
  • .env.example present and complete
  • ✅ Key parameters table is helpful

Fixes attempted

I fixed the tags and unused import locally but could not push (permission denied). The raw WebSocket → SDK migration is an architecture change (~30+ lines across demo_agent.py and the integration test) that should be handled by the fix agent.

Required changes:

  1. Rewrite demo_agent.py to use DeepgramClient.agent.v1.connect() instead of raw websockets
  2. Rewrite test_voice_agent_accepts_custom_endpoint_settings to use the SDK's agent client
  3. Add tags=["deepgram-examples"] to the Settings (fixed locally, needs push)
  4. Remove unused json import from providers.py (fixed locally, needs push)
  5. Add a .gitignore with __pycache__/

Please address the items above. The fix agent will pick this up.


Review by Lead on 2026-04-08

@github-actions github-actions bot added the status:fix-needed Tests failing — fix agent queued label Apr 8, 2026
… in 530-voice-agent-multi-provider-proxy-python

- Rewrite demo_agent.py to use DeepgramClient.agent.v1.connect() and
  send_settings() instead of raw websockets
- Rewrite integration test to use the SDK's agent client
- Add tags=["deepgram-examples"] to Settings messages
- Remove unused json import from providers.py
- Remove direct websockets dependency (SDK provides it)
- Add .gitignore with __pycache__/
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 8, 2026

Fix applied

Root cause: demo_agent.py and the integration test used raw websockets instead of the Deepgram Python SDK's agent.v1.connect() method; also missing tags=["deepgram-examples"], unused imports, and no .gitignore.

Change: Rewrote demo_agent.py and test_voice_agent_accepts_custom_endpoint_settings to use DeepgramClient.agent.v1.connect() / send_settings() with typed AgentV1Settings. Added tags=["deepgram-examples"] to all Settings messages. Removed unused json import from providers.py. Removed direct websockets pin from requirements.txt (SDK provides it). Added .gitignore with __pycache__/.

Tests after fix ✅

tests/test_example.py::test_health_endpoint PASSED                       [ 12%]
tests/test_example.py::test_models_endpoint PASSED                       [ 25%]
tests/test_example.py::test_chat_completions_missing_messages PASSED     [ 37%]
tests/test_example.py::test_chat_completions_invalid_provider PASSED     [ 50%]
tests/test_example.py::test_chat_completions_openai PASSED               [ 62%]
tests/test_example.py::test_provider_header_override PASSED              [ 75%]
tests/test_example.py::test_voice_agent_settings_builder PASSED          [ 87%]
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED [100%]

8 passed in 1.99s

✓ Fix verified — tests pass.


Fix by Lead on 2026-04-08

@github-actions github-actions bot added status:review-passed Self-review passed and removed status:fix-needed Tests failing — fix agent queued labels Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 9, 2026

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED                       [ 12%]
tests/test_example.py::test_models_endpoint PASSED                       [ 25%]
tests/test_example.py::test_chat_completions_missing_messages PASSED     [ 37%]
tests/test_example.py::test_chat_completions_invalid_provider PASSED     [ 50%]
tests/test_example.py::test_chat_completions_openai PASSED               [ 62%]
tests/test_example.py::test_provider_header_override PASSED              [ 75%]
tests/test_example.py::test_voice_agent_settings_builder PASSED          [ 87%]
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED [100%]

8 passed, 2 warnings in 2.50s

All 8 tests pass with real credentials. OpenAI provider returns valid completions. Deepgram Voice Agent WebSocket accepts custom endpoint settings and returns SettingsApplied.

Integration genuineness

✅ Pass — all 6 checks clear:

  1. Platform SDK importeddeepgram-sdk for Voice Agent API, httpx for OpenAI, boto3 for Bedrock
  2. Real API calls — OpenAI completions via httpx.post(), Bedrock via client.converse(), Deepgram via client.agent.v1.connect()
  3. .env.example lists real credentialsDEEPGRAM_API_KEY, OPENAI_API_KEY
  4. Credential gate — Test file exits with code 2 if credentials missing (lines 16-18)
  5. Bypass checkDeepgramClient usage is correct; it accesses the Voice Agent API (client.agent.v1.connect()), not raw STT/TTS. Audio flows through the Voice Agent's native STT (nova-3) and TTS (aura-2)
  6. No raw protocol — No WebSocket(), ws(), or fetch() calls for Deepgram audio; all contact through the SDK

Code quality

  • ✅ Official Deepgram SDK used — deepgram-sdk==6.1.1 (matches required version)
  • tags=["deepgram-examples"] included in Voice Agent Settings (demo_agent.py:34, test_example.py:169)
  • ✅ No hardcoded credentials — all sourced from environment
  • ✅ Error handling — missing API keys raise RuntimeError, invalid providers return 400, provider errors return 502
  • ✅ Tests import from src/proxy.app and demo_agent.build_settings tested via actual code paths
  • ✅ Server tested properly — FastAPI TestClient makes real HTTP requests to all endpoints
  • ✅ Real Deepgram API test — test_voice_agent_accepts_custom_endpoint_settings connects to agent.deepgram.com via SDK
  • ✅ No word-list assertions — all assertions check response structure (keys, types, non-empty), not specific text
  • ✅ Credential check runs first (top of test file, before any SDK imports)

Documentation

  • ✅ README includes "What you'll build" section
  • ✅ All env vars documented with where-to-get links in a table
  • ✅ Install and run instructions provided
  • ✅ "How it works" section explains the full flow
  • .env.example present and complete

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-09

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 9, 2026

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED                       [ 12%]
tests/test_example.py::test_models_endpoint PASSED                       [ 25%]
tests/test_example.py::test_chat_completions_missing_messages PASSED     [ 37%]
tests/test_example.py::test_chat_completions_invalid_provider PASSED     [ 50%]
tests/test_example.py::test_chat_completions_openai PASSED               [ 62%]
tests/test_example.py::test_provider_header_override PASSED              [ 75%]
tests/test_example.py::test_voice_agent_settings_builder PASSED          [ 87%]
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED [100%]

8 passed, 2 warnings in 2.33s

All 8 tests passed with real credentials. OpenAI provider returned valid completions. Deepgram Voice Agent accepted custom endpoint settings and returned SettingsApplied.

Integration genuineness ✅

  1. Platform SDK importeddeepgram-sdk==6.1.1 used via DeepgramClient and AgentV1Settings; OpenAI called via httpx as LLM backend; Bedrock via boto3
  2. Real API callstest_chat_completions_openai hits real OpenAI API; test_voice_agent_accepts_custom_endpoint_settings connects to real Deepgram Voice Agent WebSocket
  3. .env.example lists real credentialsDEEPGRAM_API_KEY and OPENAI_API_KEY
  4. Credential check exits 2 — test_example.py lines 15-18 exit with code 2 on missing creds before any SDK imports
  5. BYPASS CHECK: PASS — Voice Agent used through client.agent.v1.connect() via the SDK. STT/TTS run natively on Deepgram. The proxy serves as the LLM backend — no bypass of the Deepgram interface
  6. NO RAW PROTOCOL CHECK: PASS — No raw WebSocket() or fetch() for audio/transcription; SDK's agent connect method used

Code quality ✅

  • Official Deepgram SDK used (deepgram-sdk==6.1.1 — matches required version)
  • tags=["deepgram-examples"] present on Voice Agent Settings (demo_agent.py:35, test_example.py:138/169)
  • No hardcoded credentials
  • Error handling covers main failure cases (400 for bad provider/missing messages, 502 for provider errors, RuntimeError for missing API keys)
  • Tests import from src/ and call actual code (proxy.app, demo_agent.build_settings)
  • Server tests use TestClient to make real HTTP requests to FastAPI app
  • Assertions use response structure checks (choices, usage, status codes) — no word-list assertions
  • Credential check runs FIRST before SDK imports (test_example.py lines 1-18)

Documentation ✅

  • README includes "What you'll build" section
  • All env vars listed with where-to-get links
  • Install and run instructions present
  • .env.example present and complete
  • "How it works" section explains the architecture

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-09

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 9, 2026

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED

8 passed, 2 warnings in 2.58s

All 8 tests pass with real credentials. The OpenAI provider returns valid chat completions, and the Deepgram Voice Agent WebSocket accepts custom think.endpoint settings (SettingsApplied received).

Integration genuineness

Pass

  • Deepgram SDK (deepgram-sdk==6.1.1) is used for the Voice Agent connection via client.agent.v1.connect() — no bypass
  • OpenAI is called via httpx through the proxy's provider layer (real API call confirmed by test)
  • AWS Bedrock integration uses boto3.client("bedrock-runtime").converse() — real SDK call
  • No raw WebSocket or fetch calls for Deepgram API contact
  • Voice Agent settings include tags=["deepgram-examples"]
  • .env.example lists both DEEPGRAM_API_KEY and OPENAI_API_KEY
  • Credential check runs at module level (lines 6-18 of test_example.py) before any SDK imports

Code quality

  • ✅ Official Deepgram SDK used (deepgram-sdk==6.1.1 — matches required version)
  • tags=["deepgram-examples"] present in Voice Agent settings (demo_agent.py:34, test_example.py:169)
  • ✅ No hardcoded credentials — all sourced from environment
  • ✅ Error handling: provider errors → 502, validation errors → 400, missing credentials → RuntimeError
  • ✅ Tests import from src/ (proxy.app, demo_agent.build_settings) and test actual code
  • ✅ Server tests use FastAPI TestClient making real HTTP requests to endpoints
  • ✅ Voice Agent test connects to the real Deepgram API and confirms SettingsApplied
  • ✅ No word-list assertions — response structure checks only (non-deterministic safe)
  • ✅ Credential check exits with code 2 before SDK imports

Documentation

  • ✅ README includes "What you'll build" section, all env vars with where-to-get links, install/run instructions
  • .env.example present and complete for required credentials
  • ✅ Key parameters table documents Voice Agent configuration
  • ✅ "How it works" section explains the full request flow

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-09

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 9, 2026

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED

8 passed, 2 warnings in 1.80s

Real API calls confirmed:

  • OpenAI chat completion returned a valid response with token usage
  • Deepgram Voice Agent WebSocket connected, received Welcome + SettingsApplied with custom think.endpoint.url

Integration genuineness

Pass — all 6 checks satisfied:

  1. OpenAI SDK (httpx) and AWS Bedrock (boto3) imported and used for real API calls
  2. test_chat_completions_openai makes a real OpenAI API call; test_voice_agent_accepts_custom_endpoint_settings connects to real Deepgram Voice Agent API
  3. .env.example lists DEEPGRAM_API_KEY and OPENAI_API_KEY with source links
  4. Credential check at top of test file exits with code 2 if missing
  5. Deepgram Voice Agent accessed through official SDK (client.agent.v1.connect()); no bypass — STT/TTS run natively on Deepgram, LLM routes through the proxy as designed
  6. No raw WebSocket or fetch calls to Deepgram; httpx.post() in providers.py targets OpenAI/Bedrock (not Deepgram)

Code quality

  • deepgram-sdk==6.1.1 — correct required version
  • tags=["deepgram-examples"] present in AgentV1Settings (demo_agent.py + test)
  • ✅ No hardcoded credentials
  • ✅ Error handling: missing messages (400), invalid provider (400), provider errors (502), missing API keys (RuntimeError)
  • ✅ Tests import from src/ and exercise the actual proxy via FastAPI TestClient
  • ✅ Server tests make real HTTP requests to the proxy endpoints
  • ✅ Voice Agent test connects to real Deepgram WebSocket and asserts SettingsApplied
  • ✅ No word-list assertions — checks response structure only (choices, usage, content length)
  • ✅ Credential check runs first before any SDK imports

Documentation

  • ✅ README covers what you'll build, all env vars with where-to-get links, install/run instructions, architecture explanation
  • .env.example present with DEEPGRAM_API_KEY and OPENAI_API_KEY
  • ✅ Key parameters table and "How it works" flow diagram in README

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-09

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 9, 2026

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED

8 passed, 2 warnings in 2.09s

All 8 tests passed with real credentials. OpenAI provider returned valid chat completions. Deepgram Voice Agent accepted custom endpoint settings (SettingsApplied received).

Integration genuineness

Pass — all 6 checks clear:

  1. Platform SDK imported: deepgram-sdk used via DeepgramClient for Voice Agent; httpx for OpenAI; boto3 for Bedrock
  2. Real API calls: openai_completion() posts to OpenAI API; bedrock_completion() calls boto3.converse(); test connects to real Deepgram Voice Agent WebSocket
  3. .env.example lists real credentials: DEEPGRAM_API_KEY, OPENAI_API_KEY
  4. Credential check exits 2: test_example.py lines 16-18 exit with code 2 if credentials missing
  5. Bypass check: Deepgram Voice Agent accessed through client.agent.v1.connect() SDK interface — not bypassed. Proxy sits between Voice Agent and LLM providers (not in the audio path)
  6. No raw protocol: No raw WebSocket/fetch for Deepgram audio. SDK used throughout

Code quality

  • deepgram-sdk==6.1.1 — matches required version
  • tags=["deepgram-examples"] set in AgentV1Settings (demo_agent.py:35)
  • ✅ No hardcoded credentials — all read from environment
  • ✅ Error handling: 400 for missing messages/invalid provider, 502 for provider errors, RuntimeError for missing API keys
  • ✅ Tests import from src/ (proxy.app, demo_agent.build_settings) — not standalone SDK tests
  • ✅ Server tests use FastAPI TestClient for real HTTP requests to proxy endpoints
  • ✅ Voice Agent test makes real WebSocket connection and verifies Welcome + SettingsApplied
  • ✅ No word-list assertions — response checks are structural (keys present, non-empty, positive token count)
  • ✅ Credential check runs before any SDK imports (lines 5-18 of test_example.py)

Documentation

  • ✅ README includes "What you'll build", prerequisites, env vars table with links, install/run instructions, architecture walkthrough
  • .env.example present with DEEPGRAM_API_KEY and OPENAI_API_KEY
  • ✅ Key parameters table documents Voice Agent settings

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-09

@github-actions
Copy link
Copy Markdown
Contributor Author

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED                       [ 12%]
tests/test_example.py::test_models_endpoint PASSED                       [ 25%]
tests/test_example.py::test_chat_completions_missing_messages PASSED     [ 37%]
tests/test_example.py::test_chat_completions_invalid_provider PASSED     [ 50%]
tests/test_example.py::test_chat_completions_openai PASSED               [ 62%]
tests/test_example.py::test_provider_header_override PASSED              [ 75%]
tests/test_example.py::test_voice_agent_settings_builder PASSED          [ 87%]
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED [100%]

8 passed, 2 warnings in 4.67s

All 8 tests pass with real credentials. OpenAI provider returns valid completions. Deepgram Voice Agent API accepts custom endpoint settings and returns SettingsApplied.

Integration genuineness

Pass — all 6 checks satisfied:

  1. Platform SDK imported: deepgram-sdk used via DeepgramClient and AgentV1Settings; httpx for OpenAI proxy calls; boto3 for Bedrock
  2. Real API calls: test_chat_completions_openai makes a live OpenAI call through the proxy; test_voice_agent_accepts_custom_endpoint_settings connects to the real Deepgram Voice Agent WebSocket API
  3. .env.example lists real credentials: DEEPGRAM_API_KEY and OPENAI_API_KEY both present
  4. Credential guard: sys.exit(2) at top of test file before any SDK imports
  5. Bypass check: DeepgramClient is used only via client.agent.v1.connect() — the Voice Agent SDK interface. No direct STT/TTS bypass; the proxy handles LLM routing, not audio
  6. No raw protocol: No WebSocket(), ws(), or fetch() for Deepgram API contact

Code quality

  • ✅ Official Deepgram SDK: deepgram-sdk==6.1.1 (matches required v6.1.1)
  • tags=["deepgram-examples"] set in both demo_agent.py:build_settings() and in the Voice Agent test
  • ✅ No hardcoded credentials — all secrets read from env
  • ✅ Error handling: provider validation (400), missing messages (400), provider errors (502), missing credential RuntimeError
  • ✅ Tests import from src/proxy.app via FastAPI TestClient and demo_agent.build_settings
  • ✅ Server tested via real HTTP requests (FastAPI TestClient)
  • ✅ No word-list assertions — only response structure checks (choices, usage, token count > 0)
  • ✅ Credential check runs FIRST at module level before any src imports

Documentation

  • ✅ README: "What you'll build" section, all env vars with where-to-get links, install/run instructions, architecture explanation
  • .env.example present with DEEPGRAM_API_KEY and OPENAI_API_KEY
  • ✅ Key parameters table and "How it works" flow

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-10

@github-actions
Copy link
Copy Markdown
Contributor Author

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED                       [ 12%]
tests/test_example.py::test_models_endpoint PASSED                       [ 25%]
tests/test_example.py::test_chat_completions_missing_messages PASSED     [ 37%]
tests/test_example.py::test_chat_completions_invalid_provider PASSED     [ 50%]
tests/test_example.py::test_chat_completions_openai PASSED               [ 62%]
tests/test_example.py::test_provider_header_override PASSED              [ 75%]
tests/test_example.py::test_voice_agent_settings_builder PASSED          [ 87%]
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED [100%]

8 passed, 2 warnings in 2.15s

Integration genuineness

Pass — All six checks passed:

  1. Platform SDKs imported: httpx for OpenAI, boto3 for AWS Bedrock, deepgram-sdk for Voice Agent
  2. Real API calls: openai_completion() posts to OpenAI API, bedrock_completion() calls Bedrock Converse, tests hit live endpoints
  3. .env.example lists DEEPGRAM_API_KEY and OPENAI_API_KEY with source links
  4. Credential check at module level with sys.exit(2) before SDK imports
  5. Bypass check: DeepgramClient used correctly for Voice Agent WebSocket — the proxy routes LLM calls, not audio. Architecture is Voice Agent SDK → proxy → LLM providers
  6. No raw WebSocket or fetch calls for Deepgram API contact

Code quality

  • ✅ Official Deepgram SDK (deepgram-sdk==6.1.1) — correct version
  • tags=["deepgram-examples"] present in Voice Agent Settings (demo_agent.py and test)
  • ✅ No hardcoded credentials
  • ✅ Error handling: missing messages (400), invalid provider (400), provider errors (502)
  • ✅ Tests import from src/ (from proxy import app, from demo_agent import build_settings)
  • ✅ Server tested via TestClient(app) with real HTTP requests to proxy + real API calls to OpenAI and Deepgram Voice Agent
  • ✅ Assertions are structural (response shape, non-empty content, token count > 0) — no brittle word-list checks
  • ✅ Credential check runs first at module level before any SDK imports

Documentation

  • ✅ README covers what you'll build, prerequisites, all env vars with where-to-get links, install/run instructions, key parameters, architecture flow
  • .env.example present with DEEPGRAM_API_KEY and OPENAI_API_KEY

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-10

@github-actions
Copy link
Copy Markdown
Contributor Author

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED

8 passed, 2 warnings in 2.90s

All 8 tests pass including real OpenAI API calls through the proxy and a real Deepgram Voice Agent WebSocket connection with custom think.endpoint settings.

Integration genuineness

Pass — all 6 checks clear:

  1. ✅ OpenAI API called via httpx in providers.py; AWS Bedrock called via boto3.client("bedrock-runtime").converse()
  2. ✅ Real API calls — test_chat_completions_openai hits live OpenAI; test_voice_agent_accepts_custom_endpoint_settings opens a real Deepgram Voice Agent WebSocket
  3. .env.example lists DEEPGRAM_API_KEY and OPENAI_API_KEY
  4. ✅ Credential check exits with code 2 before any imports (test_example.py:17-18)
  5. ✅ Bypass check N/A — this is a proxy sitting between Voice Agent and LLM backends; Deepgram STT/TTS flows through the Voice Agent API via client.agent.v1.connect() (SDK)
  6. ✅ No raw WebSocket/fetch for Deepgram audio — all Deepgram contact uses the official SDK

Code quality

  • deepgram-sdk==6.1.1 — matches required Python SDK version
  • tags=["deepgram-examples"] present in demo_agent.py:34 and test settings
  • ✅ No hardcoded credentials; secrets read from env vars
  • ✅ Error handling: proxy returns 400 for bad provider/missing messages, 502 for provider errors
  • ✅ Tests import from src/ and test the actual proxy via TestClient(app) — not standalone SDK tests
  • ✅ Server tests make real HTTP requests through FastAPI's TestClient
  • ✅ Voice Agent test uses SDK's agent.v1.connect() to verify SettingsApplied
  • ✅ No word-list assertions — response checks are structural (keys, types, non-empty)
  • ✅ Credential check runs first at module level before SDK imports

Documentation

  • ✅ README includes "What you'll build", all env vars with where-to-get links, install/run instructions, architecture explanation
  • .env.example present with DEEPGRAM_API_KEY and OPENAI_API_KEY
  • ✅ Key parameters table documents Voice Agent config options

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-10

@github-actions
Copy link
Copy Markdown
Contributor Author

Code Review

Overall: CHANGES REQUESTED

Tests ran ✅ (7/8) / ❌ (1/8)

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings FAILED

Failure: test_voice_agent_accepts_custom_endpoint_settings — The Deepgram Voice Agent API returns "Failed to resolve endpoint: https://api.openai.com/v1/chat/completions". The think.endpoint.url should be the base URL (https://api.openai.com/v1), not the full chat completions path. Confirmed that changing the URL to https://api.openai.com/v1 makes all 8 tests pass.

Fix: In tests/test_example.py line 179, change:

"url": "https://api.openai.com/v1/chat/completions",

to:

"url": "https://api.openai.com/v1",

(Fix was committed locally but could not be pushed due to permissions.)

Integration genuineness

Pass — All 6 checks passed:

  1. ✅ Deepgram SDK imported and used (deepgram-sdk==6.1.1, client.agent.v1.connect())
  2. ✅ Real API calls to OpenAI (via httpx.post) and Deepgram Voice Agent (via SDK WebSocket)
  3. .env.example lists DEEPGRAM_API_KEY and OPENAI_API_KEY
  4. ✅ Test exits with code 2 if credentials missing (credential check at top of test file)
  5. Bypass check pass — This is a proxy server; DeepgramClient is used properly through the Voice Agent SDK (client.agent.v1.connect()), not bypassing any partner interface
  6. No raw protocol — Uses Deepgram SDK for Voice Agent connection, no raw WebSocket/fetch for Deepgram API

Code quality

  • ✅ Official Deepgram SDK used (deepgram-sdk==6.1.1 — matches required version)
  • tags=["deepgram-examples"] present in demo_agent.py:build_settings() and in test settings
  • ✅ No hardcoded credentials
  • ✅ Error handling: provider validation, missing messages, credential checks, 502 on provider errors
  • ✅ Tests import from src/ and test actual proxy code via TestClient(app)
  • ✅ Server tests use FastAPI TestClient for real HTTP requests
  • ✅ No specific word-list assertions — response structure checks only
  • ✅ Credential check runs FIRST before any SDK imports (lines 5-18 of test file)

Documentation

  • ✅ README includes: what you'll build, all env vars with where-to-get links, install/run instructions
  • .env.example present with DEEPGRAM_API_KEY and OPENAI_API_KEY
  • ✅ Key parameters table and how-it-works section

Please apply the one-line fix to tests/test_example.py:179 — change the Voice Agent think.endpoint.url from https://api.openai.com/v1/chat/completions to https://api.openai.com/v1. The fix agent will pick this up.


Review by Lead on 2026-04-10

@github-actions github-actions bot added status:fix-needed Tests failing — fix agent queued and removed status:review-passed Self-review passed labels Apr 10, 2026
…ti-provider-proxy-python

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

Fix applied

Root cause: The think.endpoint.url in the Voice Agent test used the full chat completions path (https://api.openai.com/v1/chat/completions) instead of the base URL (https://api.openai.com/v1), causing the Deepgram Voice Agent API to fail with "Failed to resolve endpoint".

Change: Changed tests/test_example.py:179think.endpoint.url from https://api.openai.com/v1/chat/completions to https://api.openai.com/v1.

Tests after fix ✅

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED
======================== 8 passed, 2 warnings in 2.41s =========================

✓ Fix verified — tests pass.


Fix by Lead on 2026-04-10

@github-actions github-actions bot added status:review-passed Self-review passed and removed status:fix-needed Tests failing — fix agent queued labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

Code Review

Overall: APPROVED

Tests ran ✅

tests/test_example.py::test_health_endpoint PASSED
tests/test_example.py::test_models_endpoint PASSED
tests/test_example.py::test_chat_completions_missing_messages PASSED
tests/test_example.py::test_chat_completions_invalid_provider PASSED
tests/test_example.py::test_chat_completions_openai PASSED
tests/test_example.py::test_provider_header_override PASSED
tests/test_example.py::test_voice_agent_settings_builder PASSED
tests/test_example.py::test_voice_agent_accepts_custom_endpoint_settings PASSED

8 passed, 2 warnings in 2.54s

All 8 tests pass with real credentials. OpenAI provider returns valid chat completion responses. Voice Agent WebSocket connection to Deepgram succeeds and receives SettingsApplied confirmation.

Integration genuineness

Pass — all 6 checks clear:

  1. Platform SDK importeddeepgram-sdk for Voice Agent, httpx for OpenAI API, boto3 for AWS Bedrock
  2. Real API calls — OpenAI chat completions via httpx.post() in providers.py:30-40; Bedrock Converse via boto3 in providers.py:55-80; Deepgram Voice Agent via client.agent.v1.connect() in demo_agent.py:92
  3. .env.example lists DEEPGRAM_API_KEY and OPENAI_API_KEY
  4. Credential guardtest_example.py:16-18 exits with code 2 on missing creds before any imports
  5. Bypass checkDeepgramClient is used only for client.agent.v1.connect() (the Voice Agent WebSocket), which is the correct SDK path. LLM calls route through the proxy as intended.
  6. No raw protocol — No WebSocket() or fetch() for Deepgram audio; SDK handles the connection

Code quality

  • deepgram-sdk==6.1.1 — correct pinned version
  • tags=["deepgram-examples"] present in Voice Agent settings (demo_agent.py:35)
  • No hardcoded credentials anywhere
  • Error handling: provider not found (400), missing messages (400), provider failures (502), missing API keys (RuntimeError)
  • Tests import from src/ via path insertion and test the actual proxy endpoints with FastAPI TestClient
  • Real Deepgram Voice Agent WebSocket test confirms SettingsApplied with custom think.endpoint
  • No word-list assertions — structure-only checks on non-deterministic LLM output
  • Proxy server correctly handles provider routing via env var and X-LLM-Provider header override

Documentation

  • README covers: what you'll build, prerequisites, all env vars with where-to-get links, install/run instructions, architecture walkthrough
  • .env.example present and complete with comment links to credential sources

✓ All checks pass. Ready for merge.


Review by Lead on 2026-04-10

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

Labels

integration:voice-agent-multi-provider-proxy Integration: Voice Agent Multi-Provider Proxy language:python Language: Python status:review-passed Self-review passed type:example New example

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants