Skip to content

Reuse shared httpx client in realtime route#16

Open
BrandonS7 wants to merge 1 commit intoBirmingham-AI:mainfrom
BrandonS7:fix/httpx-client-reuse
Open

Reuse shared httpx client in realtime route#16
BrandonS7 wants to merge 1 commit intoBirmingham-AI:mainfrom
BrandonS7:fix/httpx-client-reuse

Conversation

@BrandonS7
Copy link
Copy Markdown

What this does

backend/routes/realtime.py created a new httpx.AsyncClient() on every request to OpenAI's Realtime API. This means:

  • New TCP connection + TLS handshake per request (slow)
  • Potential connection leaks if the context manager doesn't clean up properly
  • No connection pooling benefits

Moved to a shared module-level client that reuses connections across requests. Same timeout (30s), same headers, same behavior - just without the per-request overhead.

One file changed, minimal diff.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant