Repository navigation
feat(inference, google): run GPT-Live as inference.DuplexModel, wrap Gemini 3.x reply instructions, update the realtime model list - #7673
Conversation
3f3ed2b to
91e75e1
Compare
| base_url: str | None = None, | ||
| api_key: str | None = None, | ||
| api_secret: str | None = None, | ||
| inference_class: InferenceClass | None = None, |
There was a problem hiding this comment.
should we remove this parameter if it has no effect yet?
There was a problem hiding this comment.
Removed, along with the header it fed.
| class ErrorEvent(BaseModel): | ||
| type: Literal["error"] = "error" | ||
| error: ErrorBody = ErrorBody() | ||
| def __getattr__(name: str) -> Any: |
There was a problem hiding this comment.
should we do explicit re exports instead of getattr
There was a problem hiding this comment.
Done in gpt_live_types.py and gpt_live_model.py.
theomonnom
left a comment
There was a problem hiding this comment.
GPT-Live shouldn't get its own class in inference. It's a duplex model, so it should be exposed as inference.DuplexModel, the same way the other models in this module are named by what they are: inference.LLM, inference.STT, inference.TTS, inference.RealtimeModel. Left notes on each place that needs to change.
| "TurnDetectorVersions", | ||
| "RealtimeModel", | ||
| "RealtimeSession", | ||
| "GPTLiveModel", |
There was a problem hiding this comment.
Right now this exports GPTLiveModel and GPTLiveSession from livekit.agents.inference, so users end up writing inference.GPTLiveModel(). Nothing else in this module is named after a specific model. These should be DuplexModel and DuplexSession, used as inference.DuplexModel(model="openai/gpt-live-1").
There was a problem hiding this comment.
Done in 00662e2: inference.DuplexModel / DuplexSession, taking model: DuplexModels | str.
|
|
||
| return getattr(avatar, name) | ||
| if name in ("RealtimeModel", "RealtimeSession"): | ||
| if name in ("RealtimeModel", "RealtimeSession", "GPTLiveModel", "GPTLiveSession"): |
There was a problem hiding this comment.
Same here: the lazy import currently hands out GPTLiveModel / GPTLiveSession. It should hand out DuplexModel / DuplexSession next to RealtimeModel / RealtimeSession (and the TYPE_CHECKING import on L26 too).
There was a problem hiding this comment.
Done in 00662e2: inference.DuplexModel / DuplexSession, taking model: DuplexModels | str.
| @@ -1,6 +1,9 @@ | |||
| from .gpt_live import GPTLiveModel, GPTLiveSession | |||
There was a problem hiding this comment.
This re-exports the class under the GPT-Live name. It should come out of here as DuplexModel / DuplexSession.
There was a problem hiding this comment.
Done in 00662e2: inference.DuplexModel / DuplexSession, taking model: DuplexModels | str.
| inference_class: InferenceClass | None | ||
|
|
||
|
|
||
| class GPTLiveModel(_GPTLiveModel): |
There was a problem hiding this comment.
The class itself is fine, it just has the wrong name for this module. Rename it to DuplexModel (and GPTLiveSession to DuplexSession), taking model: DuplexModels | str. The GPT-Live name is fine in the OpenAI plugin, just not here. For the GPT-Live-only arguments, see the comment on L69-71.
There was a problem hiding this comment.
Done in 00662e2: inference.DuplexModel / DuplexSession, taking model: DuplexModels | str.
|
|
||
| RealtimeModels = OpenAIRealtimeModels | XAIRealtimeModels | ||
| RealtimeModels = ( | ||
| OpenAIRealtimeModels | OpenAIGPTLiveModels | GoogleRealtimeModels | XAIRealtimeModels |
There was a problem hiding this comment.
Right now openai/gpt-live-1 is part of RealtimeModels, so is_realtime_model() returns True for it, and llm_from_model_string only picks the right class because the GPT-Live check happens first. It's a duplex model, not a realtime one. It should go in its own DuplexModels alias, with an is_duplex_model() next to is_realtime_model().
There was a problem hiding this comment.
Done. openai/gpt-live-1 moved out of RealtimeModels into its own DuplexModels, with is_duplex_model(). llm_from_model_string checks duplex, then realtime, then LLM.
| :class:`livekit.agents.inference.RealtimeModel`, every other string to | ||
| :class:`livekit.agents.inference.LLM`. | ||
| """ | ||
| if is_gpt_live_model(model): |
There was a problem hiding this comment.
With the rename this should return inference.DuplexModel for duplex model strings (and the docstring above should say so).
There was a problem hiding this comment.
Done in 00662e2: inference.DuplexModel / DuplexSession, taking model: DuplexModels | str. llm_from_model_string returns inference.DuplexModel for duplex strings, and the docstring says so.
| ``` | ||
|
|
||
| **Note:** OpenAI Realtime models are available through `inference.RealtimeModel`; use provider plugin classes for direct credentials. See the [Real-time Models](#-real-time-models) examples in `voice_agents/`. | ||
| **Note:** OpenAI Realtime and xAI Grok Voice models are available through `inference.RealtimeModel`, and OpenAI GPT-Live through `inference.GPTLiveModel`; use provider plugin classes for direct credentials or for other real-time models such as Amazon Nova Sonic. See the [Real-time Models](#-real-time-models) examples in `voice_agents/`. |
There was a problem hiding this comment.
This currently tells users to use inference.GPTLiveModel. Should be inference.DuplexModel(model="openai/gpt-live-1").
There was a problem hiding this comment.
Updated to inference.DuplexModel(model="openai/gpt-live-1").
| ``` | ||
|
|
||
| **Note:** Real-time voice-to-voice models (Amazon Nova Sonic, xAI Grok, etc.) are not supported by LiveKit Inference and must use the provider plugin directly. | ||
| **Note:** OpenAI Realtime and xAI Grok Voice models are available through `inference.RealtimeModel`, and OpenAI GPT-Live through `inference.GPTLiveModel`; use provider plugin classes for direct credentials or for other real-time models such as Amazon Nova Sonic. See the [Real-time Models](#real-time-models) examples below. |
There was a problem hiding this comment.
Same as the top-level README: inference.DuplexModel instead of inference.GPTLiveModel.
There was a problem hiding this comment.
Updated to inference.DuplexModel(model="openai/gpt-live-1").
|
|
||
| ## LiveKit Inference | ||
|
|
||
| Both examples connect to OpenAI with `OPENAI_API_KEY`. To run GPT-Live through LiveKit Inference with your LiveKit credentials instead, pass `llm="openai/gpt-live-1"` or `inference.GPTLiveModel()`; it takes the same `voice`, `delegation`, and `responses_options`. Inference runs delegated work on the default service tier only, needs `responses_options["model"]` to be an OpenAI LLM it serves (`gpt-5.6-luna` by default), and does not run hosted tools such as `WebSearch()`. |
There was a problem hiding this comment.
inference.GPTLiveModel() here should become inference.DuplexModel(model="openai/gpt-live-1").
There was a problem hiding this comment.
Updated to inference.DuplexModel(model="openai/gpt-live-1").
| Cartesia offers sonic-3 with over 40 languages, sonic-2 and sonic-turbo with 15 languages each, and the original sonic model. Deepgram offers aura-2 for English and Spanish. Inworld offers inworld-tts-1.5-max and inworld-tts-1.5-mini for 13 languages, and inworld-tts-1-max and inworld-tts-1 for 12 languages. Rime offers coda for 8 languages and mistv2 for 4 languages. | ||
|
|
||
| SUPPORTED REALTIME MODELS: | ||
| Realtime speech-to-speech models are available in Python through inference.RealtimeModel, passed as the llm argument of an AgentSession. OpenAI offers GPT Realtime 2.1 and GPT Realtime 2.1 mini, with openai/gpt-realtime and openai/gpt-realtime-mini as aliases; in regions that offer both, the provider argument pins an OpenAI model to Azure or to OpenAI directly. xAI offers Grok Voice 3.0. OpenAI's full-duplex GPT-Live 1 is available through inference.GPTLiveModel, or as llm="openai/gpt-live-1"; its delegated work runs on a backend OpenAI model that LiveKit Inference serves. Other realtime models, such as Amazon Nova Sonic, use provider plugins. |
There was a problem hiding this comment.
This says GPT-Live 1 is available through inference.GPTLiveModel. Should say inference.DuplexModel.
There was a problem hiding this comment.
Updated to inference.DuplexModel(model="openai/gpt-live-1").
theomonnom
left a comment
There was a problem hiding this comment.
A few more things on the public side. This PR is titled as a Gemini fix, but it also adds a new class to inference, changes which model names are recognized, and moves about 1,300 lines of GPT-Live code from the OpenAI plugin into livekit-agents. That last part would be a lot easier to review as its own PR.
| "openai/gpt-realtime-1.5", | ||
| "openai/gpt-realtime-2", |
There was a problem hiding this comment.
These names get removed from the list, and is_realtime_model() only recognizes what's on it. So anyone who has llm="openai/gpt-realtime-2" today now gets inference.LLM, a text model, with no error at all. Same for xai/grok-voice-think-fast-2.0 below. If these models are gone, the old names should either fail with a clear message or point to the new ones.
There was a problem hiding this comment.
Fixed in 00662e2. openai/gpt-realtime-2, openai/gpt-realtime-1.5 and xai/grok-voice-think-fast-2.0 still route to inference.RealtimeModel and log <old> is deprecated, use <new> instead. I didn't make them fail: the gateway still serves them, and cloud-config #19900 and #20197 alias them to 2.1 and 3.0. An error would break sessions that work today.
|
|
||
| OpenAIGPTLiveModels = Literal["openai/gpt-live-1"] | ||
|
|
||
| GoogleRealtimeModels = Literal[ |
There was a problem hiding this comment.
With this, llm="google/gemini-live" now builds inference.RealtimeModel, which speaks the OpenAI realtime protocol and only has special handling for xAI. Does the gateway actually translate this for Gemini end to end? The reply-instructions fix in this PR is in the Google plugin, so it doesn't apply on this path. If this isn't tested against the real service, I'd leave Gemini off this list for now.
There was a problem hiding this comment.
Yes, end to end. On this path Gemini goes through the gateway's own Gemini Live adapter, not the Google plugin. The adapter got its own fixes: reply instructions in agent-gateway#1545, session updates and manual turns in agent-gateway#1559, both live in v0.94.00. I ran the Gemini 3.8 Live models through inference.RealtimeModel against production today from Python and JS. These all passed: generate_reply(instructions=...) without leaking the prompt, manual turns, update_instructions, tools and tool_choice="none", interrupt, and text-only output. So I'd keep Gemini on the list.
| if "/" not in model: | ||
| raise ValueError("model must be provider-prefixed, for example 'openai/gpt-realtime'") | ||
| if is_gpt_live_model(model): | ||
| raise ValueError(f"{model} speaks the GPT-Live protocol; use inference.GPTLiveModel") |
There was a problem hiding this comment.
Right now is_realtime_model("openai/gpt-live-1") returns True, but passing that same name here raises. Once GPT-Live has its own DuplexModels list (see the other comment), this check goes away on its own.
There was a problem hiding this comment.
is_realtime_model() no longer matches it, but I kept the check. Without it, inference.RealtimeModel(model="openai/gpt-live-1") would open an OpenAI Realtime session against a duplex model and fail with an unclear gateway error. Now it raises openai/gpt-live-1 is a duplex model; use inference.DuplexModel.
| provider (str, optional): Host that must serve the model, e.g. ``"azure"`` or | ||
| ``"openai"`` for OpenAI models. The session is refused if no host in the | ||
| region matches. | ||
| inference_class (InferenceClass, optional): Has no effect on realtime sessions. |
There was a problem hiding this comment.
The docs here say inference_class does nothing for this class. If it has no effect, it shouldn't be an argument. Users will set it and expect something to happen.
There was a problem hiding this comment.
inference.RealtimeModel shipped this argument in 1.8.3, so removing it would break existing calls with a TypeError. I deprecated it instead: it's no longer sent, and passing it logs that it has no effect and will be removed in v2.0. It's gone entirely from DuplexModel, and from JS, where this class never shipped.
| model: Provider-prefixed GPT-Live model, ``openai/gpt-live-1`` by default. | ||
| provider: Host that must serve the model, e.g. ``"openai"``. The session is | ||
| refused if no host in the region matches. | ||
| inference_class: Has no effect on GPT-Live sessions. |
There was a problem hiding this comment.
Same as on RealtimeModel: this argument is documented as having no effect but it's still accepted, and it's also passed down into the request headers on L144. Either it does something or it should go.
There was a problem hiding this comment.
Removed, along with the header it fed.
| ) | ||
| if type(self) is GPTLiveModel: | ||
| # Preserve the pre-move metrics label for direct OpenAI sessions. | ||
| self._label = "livekit.plugins.openai.realtime.gpt_live_model.GPTLiveModel" |
There was a problem hiding this comment.
This file now lives in livekit-agents, but it hardcodes the OpenAI plugin's class path as its label. Code in livekit-agents shouldn't have to know about a plugin. The plugin can set its own label on its side.
There was a problem hiding this comment.
Done. Core no longer names the plugin. The label comes from the class, and the plugin ships a thin GPTLiveModel subclass that gets its own label. The subclass also overrides a new _provider_tool_config hook, which removes core's other plugin reference (the sys.modules lookup for OpenAITool).
|
|
||
| ## Voices | ||
|
|
||
| Both examples use `voice="marin"`. `GPTLiveVoices` also offers `aster`, `beacon`, `cinder`, `stone`, and `vesper`. Other supported names and custom voice objects still pass through to the API. |
There was a problem hiding this comment.
Small one: this lists aster, but GPTLiveVoices doesn't have it. It has cedar and marin instead.
There was a problem hiding this comment.
Fixed. The list is now beacon, cedar, cinder, stone, vesper, plus the default marin. The JS example README had the same bug and is fixed too.
theomonnom
left a comment
There was a problem hiding this comment.
Last pass, on keeping what inference exports consistent. Every model class here should look the same from the outside: named by kind (LLM, STT, TTS, RealtimeModel, DuplexModel), one XModels alias each, and constructor arguments that follow the same pattern.
| "OpenAIGPTLiveModels", | ||
| "GoogleRealtimeModels", |
There was a problem hiding this comment.
Right now inference exports one list of names per kind (STTModels, TTSModels, LLMModels, VADModels), and keeps the per-provider lists like DeepgramModels or CartesiaModels inside their modules. This adds two more per-provider lists to the exports, OpenAIGPTLiveModels and GoogleRealtimeModels. These should stay internal, and the exports should be RealtimeModels and DuplexModels, same as the other kinds.
There was a problem hiding this comment.
Done: OpenAIGPTLiveModels and GoogleRealtimeModels are no longer exported, so the exports are RealtimeModels and DuplexModels. I left OpenAIRealtimeModels and XAIRealtimeModels because main already exports them, and dropping them would break imports.
| """OpenAI GPT-Live full-duplex voice model, served through LiveKit Inference.""" | ||
|
|
||
| def __init__( | ||
| self, |
There was a problem hiding this comment.
This one has a default model, but none of the others do: inference.LLM, inference.STT, inference.TTS and inference.RealtimeModel all make you pass model. It should be required here too, typed as DuplexModels | str like LLM takes LLMModels | str.
There was a problem hiding this comment.
Done. model: DuplexModels | str, required.
| inference_class: InferenceClass | None = None, | ||
| voice: GPTLiveVoices | str | dict[str, Any] = DEFAULT_VOICE, | ||
| delegation: types.DelegationTarget = "responses", |
There was a problem hiding this comment.
Right now delegation and responses_options are their own arguments, but they only make sense for GPT-Live. inference.LLM, inference.STT and inference.TTS keep only the shared settings as arguments (voice, language, ...) and put anything model-specific in extra_kwargs. STT and TTS also use @overload so each model family gets its own typed options dict (CartesiaOptions, DeepgramOptions, ...). This should do the same: keep voice as NotGivenOr[str] = NOT_GIVEN like on RealtimeModel, and move delegation and responses_options into extra_kwargs, typed as something like OpenAIDuplexOptions.
Right now these arguments also use types inference doesn't export (GPTLiveVoices, DelegationTarget, ResponsesDelegationOptions all come from the private llm._realtime modules). With an options dict that lives in inference, that problem goes away too.
There was a problem hiding this comment.
Done. voice is NotGivenOr[str] = NOT_GIVEN, and delegation / responses_options moved into extra_kwargs. They're typed with @overload as OpenAIDuplexOptions and OpenAIResponsesOptions, both defined in inference, so nothing private leaks. Unknown keys raise, and a non-default service_tier is still refused.
…ider and inference_class
Move the GPT-Live client into livekit-agents core (llm/_realtime/gpt_live.py); livekit.plugins.openai.realtime.GPTLiveModel re-exports it and keeps its metrics label. Add inference.GPTLiveModel, which connects to the gateway's /live/sessions?model= with a LiveKit token signed per connection, and resolve llm="openai/gpt-live-1" to it. It refuses what the gateway cannot meter before connecting: hosted tools and a non-default delegation service tier. Gateway refusals of session.start are fatal.
- DuplexModels / is_duplex_model split GPT-Live out of RealtimeModels - DuplexModel takes a required model, voice as a string, and GPT-Live's delegation / responses_options through extra_kwargs (OpenAIDuplexOptions) - drop the no-op inference_class from DuplexModel; deprecate it on RealtimeModel - keep retired realtime ids (gpt-realtime-2, -1.5, grok-voice-think-fast-2.0) routed to RealtimeModel with a warning naming the replacement - stop exporting the per-provider GoogleRealtimeModels / OpenAIGPTLiveModels - the OpenAI plugin subclasses GPTLiveModel for its own label and hosted tools, with explicit re-exports instead of module __getattr__ - docs: inference.DuplexModel, cedar instead of aster
- a failed first handshake retried as a reconnection, which discarded replies requested during startup; it now retries as a fresh connection - commit_audio sends the buffered partial frame; clear_audio drops it
…ports Core no longer hardcodes the OpenAI plugin's class path. The plugin ships a thin RealtimeModel subclass, so its label comes from the class, and with_azure builds cls(...) and returns Self. realtime_model.py and utils.py re-export by name instead of import * plus __getattr__.
4aa2420 to
9b7a144
Compare
Azure retired the preview realtime API (realtime_beta_access_required), and api_version is deprecated.
…mini-transcribe deployment
theomonnom
left a comment
There was a problem hiding this comment.
Looks good, thanks. The inference API is consistent now: DuplexModel next to RealtimeModel, model-specific options in extra_kwargs, and nothing private in the signatures.
main (livekit#7673) moved the GPT-Live session into livekit-agents/livekit/agents/llm/_realtime/gpt_live.py, so the credit_balance_exhausted fatal code now goes into that file's _FATAL_ERROR_CODES instead of the plugin's gpt_live_model.py.
Rebase onto main was blocked (OAuth token lacks workflow scope for .github/workflows from livekit#7673/livekit#7779). Resolve the conflict in-place: keep main's generate_reply wrapping for Gemini 3.x and test_reply_instructions_turns_follow_the_model from livekit#7673; retain only the Vertex role="system" update_instructions fix and test_update_instructions_role_for_api.
Bring the branch tip in line with upstream main (except .github/workflows, which the OAuth token cannot update) so GitHub can merge without the livekit#7673 conflict. Keeps the Vertex role="system" update_instructions fix and test_update_instructions_role_for_api; preserves main's generate_reply wrapping and test_reply_instructions_turns_follow_the_model.
Match tests/test_plugin_google_realtime.py to main (keeps test_reply_instructions_turns_follow_the_model). Leave the Vertex role="system" change in update_instructions. Follow-up commit will re-add test_update_instructions_role_for_api after Update branch.
Cover Vertex role="system" vs Gemini role="model" for mid-session update_instructions (livekit#7785). Placed above the livekit#7673 reply-instructions test so the branch stays mergeable without a workflow-scoped rebase.
Keep main's generate_reply wrapping and test_reply_instructions_turns_follow_the_model from livekit#7673. Only the Vertex role="system" update_instructions change and test_update_instructions_role_for_api remain on top.
main (livekit#7673) moved the GPT-Live engine from the OpenAI plugin into livekit.agents.llm._realtime, leaving the plugin modules as re-export shims. The tracing changes are ported onto the moved engine and types, and _gpt_live_telemetry moves alongside them, so the hosted inference DuplexModel and the plugin share the same backend and protocol spans. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Combines eight changes, previously #7673, #7346 and #7678, plus GPT-Live under LiveKit Inference as
inference.DuplexModel(change 5), single-final-transcript turn handling on hosted xAI (change 6), two realtime session fixes (change 7), and the direct OpenAI Realtime plugin owning its label (change 8). Changes 3 through 6 all edit the realtime model lists,llm_from_model_stringand the inference docs, so they stay in one PR rather than landing in a forced order.Note
Reviewing the GPT-Live move. Most of the line count is the GPT-Live client moving from the OpenAI plugin into
livekit-agents, whichinference.DuplexModelsubclasses. GitHub shows it as an add plus a delete because the plugin files stay as re-export shims, but only 50 of its ~1,300 lines change (3 in the types file). To see just those:Important
Ordering: cut the release containing this after these have deployed:
xai/grok-voice-think-fast-2.0withxai/grok-voice-3.0in the gateway and catalog, and aliases the old id to 3.0.provideron realtime, contrary to the new docstring and knowledge-base text.livekit/cloud-config#19900 no longer blocks the release. The retired
openai/gpt-realtime-2and-1.5ids still resolve toinference.RealtimeModel(with a deprecation warning), so they keep working before and after it aliases them to 2.1.1. fix(google): send Gemini 3.x reply instructions as a wrapped user turn
Problem
On Gemini 3.1 and 3.8 Live,
generate_reply(instructions=R)sendsRas a trailingmodel-role turn. #7289 dropped the"."user placeholder on these models, and nothing else was changed. Gemini then treatsRas its own unfinished turn and continues it, instead of answering it.I ran this directly against
gemini-3.8-live(Gemini API, no gateway), seeding one user/model exchange and then callinggenerate_reply. Over 15 runs, only 4 were clean:Ritself;Fix
When the model takes no placeholder, send
Ras auserturn wrapped in_DEFAULT_INLINE_INSTRUCTIONS_TEMPLATE. That is the shapeconvert_mid_conversation_instructionsalready givesgenerate_replyinstructions on the Gemini LLM path. Placeholder models (2.5) keepmodel+".".The wrapping matters. I followed each reply with "repeat back every message I've said to you":
userturn was quoted back as the caller's own words 5/5 times;On 2.5 the current shape is the better one:
model+"."was clean 5/5, while the wrapped user turn was quoted back 3/5. So this change is gated on the existing placeholder check.Vertex AI
I repeated the comparison on Vertex AI (
gemini-3.8-live,us-central1), with 10 runs per shape:userturn was clean 10/10;userturn was quoted back as the caller's words 8/10 times;modelturn did much better than on the Gemini API: 9/10 clean, though once it recited the system prompt and some JSON.Vertex documents mid-session system instruction updates (a
role="system"turn). That doesn't steer a single reply:systemturn withturnComplete: trueproduced no reply (3/3);systemupdate followed by an emptyturnCompleteproduced no reply either (5/5), and in 2 of those runs the instruction came out in the answer to the next, unrelated question.On the Gemini API, both
role="system"and an unset role close the session with1007. Neither API has a per-reply mechanism, so this keeps to the documenteduser/modelroles.The Inference gateway had the same issue for
google/gemini-3.8-live; it is fixed in livekit/agent-gateway#1545, in production since v0.93.60.2. docs: correct stale OpenAI Realtime Inference availability claims
After the OpenAI Realtime inference client moved into agents core (
inference.RealtimeModel, #7318), two docs still said OpenAI Realtime is unavailable through LiveKit Inference and needs the provider plugin:examples/homepage/knowledge_base/products/livekit-inference.mdis loaded at runtime by the homepage agent, so it was steering users away from Inference for realtime. It now lists the realtime models.examples/voice_agents/README.mdcontradictedexamples/README.md.Both now list xAI Grok Voice as available through
inference.RealtimeModeltoo. The first commit is from the Doc Drift bot.3. fix(inference): retire gpt-realtime-1.5 and -2 from the realtime model list
Removes
openai/gpt-realtime-1.5andopenai/gpt-realtime-2fromOpenAIRealtimeModels. With livekit/cloud-config#19900, LiveKit Inference serves onlygpt-realtime-2.1and-2.1-mini;openai/gpt-realtimeand-miniresolve to those two, and the retired ids alias to 2.1.The retired ids move to
DEPRECATED_REALTIME_MODELS, whichis_realtime_model()still recognizes.llm="openai/gpt-realtime-2"keeps buildinginference.RealtimeModelrather than the textLLM, and logsopenai/gpt-realtime-2 is deprecated, use openai/gpt-realtime-2.1 instead.The direct OpenAI and Azure plugins are unchanged, since they run on the customer's own key.
4. fix(inference): replace Grok Voice Think Fast 2.0 with Grok Voice 3.0; document realtime
provider; deprecate realtimeinference_classxai/grok-voice-think-fast-2.0withxai/grok-voice-3.0inXAIRealtimeModelsandgrok-voice-think-fast-2.0withgrok-voice-3.0in the xAI plugin'sGrokRealtimeModels, matching livekit/cloud-config#20197.xai/grok-voice-think-fast-2.0stays a deprecated id, as in change 3, pointing toxai/grok-voice-3.0.provideroninference.RealtimeModel: it pins the hosting engine, and the session is refused if no host in the region matches. This is the behavior livekit/agent-gateway#1572 adds, matchinginference.LLM.inference_classoninference.RealtimeModel. The gateway ignores the priority header on realtime: sessions have no priority tier and are bounded by the concurrent-session quota, not paced. It is no longer sent, and passing it logs that it has no effect and will be removed in v2.0. It shipped in 1.8.3, so it stays accepted until then.5. feat(inference): run OpenAI GPT-Live through LiveKit Inference as
inference.DuplexModelGPT-Live previously needed
openai.realtime.GPTLiveModeland the customer's own OpenAI key. It now runs on LiveKit credentials:livekit.agents.llm._realtime.gpt_live. The plugin modules re-export them explicitly.openai.realtime.GPTLiveModelis a thin subclass of the core class, so it keeps its own metrics label without core naming the plugin.OpenAITool) through a_provider_tool_confighook, so core doesn't reference the plugin. It doesn't duck-type onto_dict, because the Anthropic, xAI, Mistral and Google tools have that method too.inference.DuplexModelis shaped like the otherinferenceclasses: named by kind,model: DuplexModels | strrequired, shared settings (voice,provider) as arguments, and GPT-Live'sdelegationandresponses_optionsinextra_kwargs, typed per model with@overloadasOpenAIDuplexOptions. Unknownextra_kwargskeys raise. It is separate frominference.RealtimeModelbecause GPT-Live speaks a different protocol.{inference url}/live/sessions?model=openai/gpt-live-1and signs a fresh LiveKit token for each connection.providerbehaves as oninference.RealtimeModel. There is noinference_class.RealtimeError, since the gateway refuses non-function tools.extra_kwargs["responses_options"]["service_tier"]must be unset or"default".invalid_model,unsupported_server_tool,unsupported_service_tier,invalid_delegated_modelandunsupported_delegated_model.openai/gpt-live-1is in its ownDuplexModelsalias withis_duplex_model(), not inRealtimeModels.llm="openai/gpt-live-1"resolves toinference.DuplexModel, andAgentSessionandAgentwrap it in the duplex adapter as they do for the direct model.inference.RealtimeModelrejects duplex ids and points toinference.DuplexModel.google/gemini-3.8-live,google/gemini-3.8-live-extended-thinkingandgoogle/gemini-livejoinRealtimeModels, sollm="google/gemini-3.8-live"resolves toinference.RealtimeModel. The gateway's Gemini adapter has the matching fixes in livekit/agent-gateway#1545 (reply instructions) and add changeset: google-genai version update #1559 (session updates and manual turns).inferenceexportsRealtimeModelsandDuplexModels, one alias per kind; the new per-provider lists stay internal.GPTLiveVoicesreplaces"aster"(which OpenAI rejects withforbidden/"Voice session access denied.") with"cedar", and"forbidden"is treated as a fatal error code so a refused voice doesn't retry 3 times.DuplexSession._report_connection_acquiredandRealtimeSession._report_connection_acquiredsetlabel=on connection-timingRealtimeModelMetrics.RealtimeSession.update_optionsonly attachesaudio.inputoraudio.outputwhen that side changed, preventing an emptyaudio.input: {}on a voice update from clearinginput_audio_transcriptionon xAI.interrupt()suppressChanClosed.input_audio_transcription.completeduntil the agent speaks (6c93c3c23), emitting one final user transcript per turn.inference.DuplexModel(model="openai/gpt-live-1").Production already serves
gpt-live-1(it is in the catalog, with an EU route since livekit/cloud-config#20355), so this change doesn't change the release ordering above.6. fix(inference): emit one final user transcript per turn on hosted xAI
The gateway forwards xAI's
conversation.item.input_audio_transcription.completedevents unchanged (livekit/agent-gateway#1579). Unlike OpenAI, xAI sends.completedmultiple times for one user item (status: "in_progress"partials, and a fresh full-item transcript on each commit across pauses within a turn).inference.RealtimeSessionsubclasses the base OpenAI session directly rather than the xAI plugin, so hostedxai/…sessions treated every.completedas final and added duplicate user items.When
modelstarts withxai/,inference.RealtimeSessionnow applies the same turn-state handling aslivekit.plugins.xai.realtime.RealtimeSession(#6729):.completedevents in_pending_transcription, emitsis_final=Falseas they arrive, and flushes a single final transcript when the agent starts speaking or generating text, the next user turn starts, the session reconnects, oraclose()runs;update_chat_ctxdiffs, appends unanchoredconversation.item.addeditems to the tail, and discards responses xAI abandoned before speaking.Hosted
openai/…sessions are unchanged.7. fix(realtime): retry a refused first handshake as a fresh connection; flush turn audio
Both found while validating review findings on the JS port (livekit/agents-js#2532), and both affect direct and hosted OpenAI-protocol sessions:
_main_tasksetreconnectingafter every attempt, so when the first handshake failed (e.g. a 503), the retry ran the reconnection replay. That rejected anygenerate_reply()requested during startup with "pending response discarded due to session reconnection", and emittedsession_reconnectedfor a session that never connected.reconnectingis now set once a connection opens. The startup events are still queued, so the fresh connection sends them.AudioByteStreamsends 100 ms frames and holds the remainder.commit_audiocommitted without it, so up to 90 ms of a client-committed turn's tail went out at the start of the next turn, andclear_audioleft the stale remainder in place.commit_audionow sends the partial frame before committing, andclear_audiodiscards it.8. refactor(openai): plugin
RealtimeModelowns its label; explicit re-exportsThis gives the OpenAI Realtime client that #7318 moved into core the same cleanup change 5 gives GPT-Live:
llm/_realtime/openai.pyno longer hardcodeslivekit.plugins.openai.realtime.realtime_model.RealtimeModelas its label.openai.realtime.RealtimeModelis now a thin subclass, so the label comes from the class and is unchanged for users.with_azurebuildscls(...)and returnsSelf, soopenai.realtime.RealtimeModel.with_azure(...)still returns the plugin class.realtime_model.pyandutils.pyre-export by name instead ofimport *plus__getattr__. Every public name either module defines is still importable, as are the three private helpers xAI and the tests import (_DiscardedGeneration,_MessageGeneration,_is_fatal_error). Names that were only reachable through the wildcard, such asrealtime_model.logger, are not.Note
inference.RealtimeModel(and itsopenai.realtime.InferenceRealtimeModelalias) is no longer a subclass ofopenai.realtime.RealtimeModel, soisinstance(inference_model, openai.realtime.RealtimeModel)is nowFalse. Both still subclass the core OpenAI Realtime class and shareRealtimeSession. Nothing in the repo relied on the old relation, and GitHub code search found no external uses.Tests
test_reply_instructions_turns_follow_the_modelcovers 3.8, 3.1 and 2.5; the 3.x cases fail without the fix.test_gpt_live_model.pyadds a "LiveKit Inference" section.modelquery, a re-signed bearer token on reconnect, the provider header, that no tier header is sent, and thesession.startmodel, voice and Responses options passed throughextra_kwargs.extra_kwargs, hosted-tool refusal, the default-tier-only rule, fatal gateway codes, other providers' tools being ignored, and the plugin and inference classes each getting their own label.test_inference_model_string.pycovers the GPT-Live string, its duplex wrapping inAgentSession, and the retired realtime ids.test_openai_inference_realtime_model.pycovers the duplex-id guard and the deprecation warnings for retired ids andinference_class.test_openai_realtime_model.pycovers change 7: a server that refuses the first handshake with a 503 still answers agenerate_reply()made during startup without a reconnection, a commit carries the turn's partial frame, and a clear drops it. All three fail without the fix.test_direct_model_preserves_public_label_and_model_typescovers change 8: the plugin label,with_azurereturning the plugin class, the sharedRealtimeSession, andinference.RealtimeModelnot subclassing the plugin class.uv run pytest tests/test_gpt_live_model.py tests/test_inference_model_string.py tests/test_realtime/test_openai_inference_realtime_model.py tests/test_realtime/test_openai_realtime_model.py tests/test_realtime/test_xai_realtime_model.py tests/test_plugin_google_realtime.py tests/test_openai_realtime_chat_ctx.py tests/test_plugin_openai_realtime_reasoning.py tests/test_realtime_*.py tests/test_config.py: 482 passed.wss://agent-gateway.livekit.cloud/v1) acrossopenai/gpt-live-1(all Responses delegation options, function tool round-trip withLLMMetrics, client delegation,max_session_durationreconnect, mute/unmute, context appends, and all voices),openai/gpt-realtime-2.1,google/gemini-3.8-live,google/gemini-3.8-live-extended-thinking, andxai/grok-voice-think-fast-2.0. The GPT-Live run predates theDuplexModelrename, which doesn't change the wire protocol. Gemini (generate_replyinstructions, manual turns,update_instructions, tools andtool_choice="none", interrupt, text-only) was re-verified on 14 October against gateway v0.94.00.ruff format --check,ruff checkandmypy: clean.