Add reasoning.effort support for OpenAI gpt-realtime-2 Feature Type Would make my life…
- User
Add reasoning.effort support for OpenAI gpt-realtime-2
Feature Type
Would make my life easier
Feature Description
OpenAI
gpt-realtime-2supports configurable reasoning viareasoning.effort, but the Python OpenAI Realtime plugin does not seem to expose this option onopenai.realtime.RealtimeModel.It would be useful to support something like:
from livekit.plugins import openai llm = openai.realtime.RealtimeModel( model="gpt-realtime-2", reasoning={"effort": "low"}, )Workarounds / Alternatives
I don't think there is a clean workaround through the current Python
RealtimeModelAPI.The only workaround I can see is patching the plugin locally to add
reasoningto the session update payload.Additional Context
OpenAI docs list these effort values:
minimal,low,medium,high,xhigh.References:
- https://developers.openai.com/api/docs/models/gpt-realtime-2
- https://developers.openai.com/api/docs/guides/realtime-models-prompting#set-reasoning-effort
- Related JS issue: https://github.com/livekit/agents-js/issues/1433
- Related JS PR: https://github.com/livekit/agents-js/pull/1575
Interface
No new interfaces are introduced.
- Assistant
I'll add
reasoning.effortsupport to the OpenAI Realtime plugin by exploring the current implementation and the related JS changes. - Assistant
Implementing
reasoning.effortsupport to match the JS plugin: add it to options and include it in the session update payload forgpt-realtime-2models. - Assistant
Creating unit tests and running them:
- Assistant
Switching to
RealtimeReasoning— the correct type for the realtime session API. - Assistant
Added
reasoning.effortsupport to the OpenAI Realtime plugin, matching the agents-js implementation.Usage
from livekit.plugins import openai llm = openai.realtime.RealtimeModel( model="gpt-realtime-2", reasoning={"effort": "low"}, )You can also pass a
RealtimeReasoningobject, or update it at runtime viaupdate_options(reasoning={"effort": "high"}).Changes
reasoningparameter onRealtimeModel.__init__andupdate_options(model + session)to_reasoning()helper inutils.py— normalizes dict orRealtimeReasoninginput- Session update payload —
reasoningis included only when:- A value is set, and
- The model name starts with
gpt-realtime-2
Supported effort values per the OpenAI API:
minimal,low,medium,high,xhigh.Tests
Added
tests/test_openai_realtime_model.pywith unit tests covering session update inclusion/exclusion and behavior. All 4 tests pass.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.