Skip to content

fix(openai): include model in gateway websocket urls#2032

Merged
toubatbrian merged 1 commit into
mainfrom
port-openai-websocket-model-url
Jul 14, 2026
Merged

fix(openai): include model in gateway websocket urls#2032
toubatbrian merged 1 commit into
mainfrom
port-openai-websocket-model-url

Conversation

@rosetta-livekit-bot

@rosetta-livekit-bot rosetta-livekit-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Port Python fix for OpenAI Responses WebSocket URL routing to the JS OpenAI plugin.
  • Include model on Responses WebSocket upgrade URLs for non-OpenAI gateway hosts only.
  • Preserve native OpenAI behavior by omitting model from api.openai.com WebSocket URLs.
  • Accept source-style full /responses base URLs without appending /responses twice.

Source diff coverage

Coverage classification
  • livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/responses/llm.py: adapted to plugins/openai/src/ws/llm.ts. The JS target splits Responses HTTP wrapper (responses/llm.ts) from Responses WebSocket implementation (ws/llm.ts), so the URL construction belongs in ws/llm.ts; parity is implemented by omitting model for native api.openai.com and adding it for gateway hosts, while preserving HTTP-to-WS scheme conversion. The target also keeps JS baseURL root semantics and now accepts source-style full /responses URLs without duplication.
  • livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py: ported to plugins/openai/src/stt.ts. The target already had the equivalent buildRealtimeSttUrl behavior: intent=transcription always, model only for non-native OpenAI hosts, and HTTP-to-WS scheme conversion, so no code change was needed.
  • tests/test_plugin_openai_websocket_urls.py: adapted to plugins/openai/src/stt.test.ts and plugins/openai/src/ws/llm.test.ts. The target co-locates Vitest tests with each module and exposes URL builder helpers, so the source’s private fake-session URL assertions map to helper-level URL assertions rather than a new cross-plugin test file. Existing STT URL tests already covered the STT source cases; Responses WS tests were updated/extended for native omission, gateway inclusion, scheme conversion, and full /responses endpoint handling.

Verification

  • pnpm build
  • pnpm --filter @livekit/agents-plugin-openai lint (passes with pre-existing warnings)
  • env -u OPENAI_API_KEY pnpm test -- plugins/openai
  • cue-cli runtime validation against a temporary uncommitted JS worker using openai.responses.LLM({ useWebSocket: true }): assistant conversation_item_added framework events resolved for greeting and a user turn.

Note: pnpm test -- plugins/openai with the ambient OPENAI_API_KEY set entered optional provider integration tests and failed on existing environment/test prerequisites (plugins/silero/dist/silero_vad.onnx parse failure and an existing realtime STT-without-VAD construction in tts.test.ts). The suite passes when provider integrations follow their built-in skip path with OPENAI_API_KEY unset.


Ported from livekit/agents#6403

Original PR description

Summary

  • include the selected model in realtime STT WebSocket upgrade URLs
  • include the selected model in Responses API WebSocket upgrade URLs while preserving existing query parameters
  • add hermetic regression tests for both upgrade paths

Test plan

  • uv run pytest tests/test_plugin_openai_websocket_urls.py --unit
  • uv run ruff check livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/responses/llm.py tests/test_plugin_openai_websocket_urls.py
  • uv run ruff format --check livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/responses/llm.py tests/test_plugin_openai_websocket_urls.py
  • make type-check

@rosetta-livekit-bot rosetta-livekit-bot Bot requested a review from a team as a code owner July 14, 2026 16:13
@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e8533fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-xai Patch
@livekit/agents Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugins-test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@toubatbrian toubatbrian merged commit c0c927a into main Jul 14, 2026
8 checks passed
@toubatbrian toubatbrian deleted the port-openai-websocket-model-url branch July 14, 2026 17:10
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
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