feat: add OpenAI Realtime support to live runs - #6579
Open
GitMarco27 wants to merge 3 commits into
Open
Conversation
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Description of Change
Problem:
The experimental
OpenAILlmintegration supports regular Chat Completions requests but cannot be used with ADK's standardRunner.run_live()flow.Applications that need bidirectional voice or text streaming with OpenAI Realtime models therefore require provider-specific connection code outside ADK's standard live architecture.
Solution:
Implement
OpenAILlm.connect()using the official OpenAI Python SDK Realtime connection and add an ADKBaseLlmConnectionadapter for the OpenAI Realtime API.The adapter:
Runner.run_live()andLiveRequestQueue;NO_INTERRUPTION;AsyncOpenAIclient or asynchronous API key provider;This initial implementation targets the public OpenAI API only. Azure OpenAI Realtime and LiteLLM Realtime proxies are intentionally outside the scope of this PR.
Usage example
OpenAI Realtime uses the standard ADK live flow; no provider-specific runner is required. The existing
App,Runner, and session setup remains unchanged.Here,
microphone_stream()represents an application-provided asynchronous source of PCM16 mono 24 kHz audio.A complete prerecorded-file streaming example, including
App,Runner, and session setup, is available in thegoogle.adk.labs.openaiREADME.Testing Plan
Unit Tests:
Test results:
uv run pytest tests/unittests/labs/openai -q104 passed53 passed53 passedon every Python versionThe full
tests/unittestssuite was also run across Python 3.10–3.14. All new and OpenAI-related tests pass.Each environment reports the existing failure:
tests/unittests/cli/utils/test_cli_tools_click.py::test_telemetry_cli_commandsThe same failure was reproduced on an unmodified checkout of the current upstream
main, where the command exits with status 2 instead of the status 0 expected by the test. It is therefore unrelated to this change and is notmodified as part of this PR.
One unrelated
test_load_web_page_blocks_file_scheme_urlsfailure occurred once during the parallel Python 3.13 run and passed immediately when rerun in isolation.Manual End-to-End (E2E) Tests:
OPENAI_API_KEY.RunnerwithOpenAILlm(model="gpt-realtime").audio_stream_endand consume events untilturn_complete.Observed result:
The returned audio was verified as PCM16 little-endian, mono, 24 kHz, with a duration of 4.9 seconds.
Checklist
Additional context
The implementation is intentionally contained in the existing experimental
google.adk.labs.openaipackage and does not introduce a provider-specific runner.This PR fully addresses #2719. It also addresses the public OpenAI portion of #1045; LiteLLM Realtime proxy support remains out of scope.
Current documented limitations: