Repository navigation
feat(gemini): live avatar support for gemini-3.8-live (avatar config, video deltas, video tokens) - #47158
feat(gemini): live avatar support for gemini-3.8-live (avatar config, video deltas, video tokens)#47158tech-carrement wants to merge 5 commits into
Conversation
Merging this PR will not alter performance
|
… video deltas, video tokens) Gemini 3.8 Live can render a lip-synced avatar: the setup takes avatarConfig and responseModalities ["VIDEO"], and the model streams fragmented MP4 (H.264 + AAC) blobs as video/mp4 inlineData parts, continuously and outside any turn. - session.update `avatar` -> setup.avatarConfig.avatarName and `avatar_video_bitrate_bps` -> avatarConfig.videoBitrateBps (the default stream is about 8 Mbit/s); output_modalities ["video"] already maps to VIDEO - video/* inlineData parts become response.output_video.delta events instead of being appended to the audio delta; a video-only model turn is a side channel that opens no response, the spoken turn is opened by its output transcript and closed by generationComplete like any audio item - video output tokens survive into response.done usage (output_token_details.video_tokens) Refs BerriAI#43166
c08f254 to
04f8c5c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Main now filters response modalities down to TEXT and AUDIO, both when it validates session.update and when it builds the setup, which dropped or refused the VIDEO modality an avatar session answers in. VIDEO is producible when the session asks for an avatar (avatarConfig in the setup), and wins over AUDIO when both are requested since the video stream carries the audio.
Main opens a transcript-first item as audio itself, so the avatar path no longer needs its own fallback, and the input transcription check goes back to main's shape.
…etes Since BerriAI#39864 the setup goes out with the first content and the content follows right away. An audio setup completes fast enough, but a Live Avatar (video) setup does not: Gemini answers the first item with the text "Error: Session is not set up yet" and drops it. Every client frame except the session.update that triggers the setup, held content included, now waits for setupComplete.
|
Merged main ( |
TLDR
Problem this solves:
avatarConfig+responseModalities: ["VIDEO"]), and the model then streams fragmented MP4 (H.264 + AAC-LC) blobs asvideo/mp4inlineData parts, continuously and outside any turnresponse.output_audio.delta, and a video-only frame would open a phantom OpenAI responsecandidatesTokensDetailsmodalityVIDEO) were dropped fromresponse.doneusagesession.updateand when building the setup), avideorequest is refused or silently downgraded to audioError: Session is not set up yetand drops it, every timeHow it solves it:
session.updateavatar(prebuilt avatar name) maps tosetup.avatarConfig.avatarName, andavatar_video_bitrate_bpstoavatarConfig.videoBitrateBps(Google's default stream is about 8 Mbit/s);output_modalities: ["video"]already mapped toVIDEOvideo/*inlineData parts becomeresponse.output_video.deltaevents (a newOpenAIRealtimeOutputVideoDeltaTypedDict in the realtime event union:delta= base64 fMP4 chunk,mime_type, currentresponse_id/item_idor null) instead of polluting the audio deltagenerationCompletelike any audio item (the audio is muxed in the MP4, no audio part ever arrives)response.doneusage.output_token_details.video_tokensavatarConfigin the setup), and wins over AUDIO when both are requested since the video stream carries the audio; without an avatar it is still refused or dropped as beforegemini_live_defer_setup, every client frame except thesession.updatethat triggers the setup, held content included, waits forsetupComplete. This is the frame hold first proposed in fix(realtime): buffer every client frame until the deferred gemini setup completes #47131 and then in fix(gemini): gemini live bridge fidelity (vad, barge-in, language, response.create, output items) #47172; it was dropped from fix(gemini): gemini live bridge fidelity (vad, barge-in, language, response.create, output items) #47172 because audio setups win the race on main (20/20), but avatar setups lose it (proof below), so it lives here with the feature that needs itUser Flow
Before: a developer asks for the avatar on
ws://localhost:4000/v1/realtime?model=gemini-livesession.updatewithoutput_modalities: ["video"]1007: Avatar config is required for avatar mode.and there is no field to pass itAfter: the same developer adds
avatar: "Ben"to the sessionresponse.output_video.deltafrom the first seconds, a few per 100 msresponse.donereports the video tokensRelevant issues
Closes #43166
Pre-Submission checklist
tests/unitdirectory, Adding at least 1 test is a hard requirementmake test-unitProof of Fix
After merging main (21 Nov 2026, main at
754c2225d7)Live LiteLLM proxy,
vertex_ai/gemini-3.8-liveineu,gemini_live_defer_setup: true, real calls. Same client as below:session.updatewithoutput_modalities: ["video"],avatar: "Ben",avatar_video_bitrate_bps: 1500000, voicePuck, then one user text item oncesession.updatedarrives. Five sessions per tree.main
754c2225d7(no avatar support): the avatar is ignored and the answer comes back as audio onlythis branch without the frame hold (
925beddb4c): 0/5, the first item loses the race to the video setupthis branch (
217366b5b0): 4/5The 1011 is on Google's side: the same client against a build of this feature on a 1.107 base fails the same way in 1 run out of 10, see Caveats.
New unit tests:
test_gemini_video_output_is_accepted_only_with_an_avatar,test_gemini_avatar_session_keeps_video_when_audio_is_requested_too(tests/unit/llms/gemini/realtime/test_gemini_realtime_transformation.py) andtest_deferred_setup_holds_every_client_frame_until_backend_setup_complete(tests/unit/litellm_core_utils/test_realtime_streaming.py); they fail without the matching change.Original proof (October, before main was merged)
Live LiteLLM proxy,
vertex_ai/gemini-3.8-liveineu(api_base: https://aiplatform.eu.rep.googleapis.com), real calls. Client:session.updatewithoutput_modalities: ["video"],avatar: "Ben",avatar_video_bitrate_bps: 1500000, voicePuck, then one user text item oncesession.updatedarrives.Before, merge base
46ae68021e:After, at
04f8c5c1a6(the code commit;d7817d673eon top only adds the coverage-matrix note):The concatenated deltas of a session are a valid fragmented MP4 (
ffprobe: h264 704x1280 24 fps + aac 24 kHz mono). Unit tests intests/unit/llms/gemini/realtime/test_gemini_realtime_transformation.py:test_gemini_avatar_session_update_emits_video_modality_and_avatar_config,test_gemini_avatar_video_bitrate_is_mapped,test_gemini_video_inline_data_becomes_output_video_delta,test_gemini_video_only_frame_emits_no_audio_delta,test_gemini_video_only_frame_never_opens_a_response,test_gemini_transcript_opened_response_is_closed_by_generation_complete,test_gemini_video_output_tokens_survive_response_doneType
🆕 New Feature
Caveats
response.output_video.deltais not an OpenAI realtime event; it is the natural sibling ofresponse.output_audio.delta, and clients that do not know it ignore it. Happy to rename if there is a preferred vocabularyavatarandavatar_video_bitrate_bpsare new session fields with no OpenAI counterpart; custom avatars (customized_avatar, allowlist-only at Google) are not coveredsetupCompletedelays the first content of every deferred Gemini Live session by the setup time (about 100 ms for audio), not only avatar sessions1011 Internal error encountered, at the same rate on a 1.107-based build of this feature: not caused by this changeFinal Attestation