icy-beard-64788
12/10/2025, 5:24 PMtall-airline-16756
12/10/2025, 5:24 PMtall-airline-16756
12/10/2025, 5:24 PMicy-beard-64788
12/10/2025, 5:26 PMtall-airline-16756
12/10/2025, 5:27 PMfrom livekit.plugins import liveavatar
avatar = liveavatar.AvatarSession(avatar_id="your_avatar_id")
4) Use an AgentSession with a realtime model
• Use any RealtimeModel (OpenAI Realtime, Azure OpenAI Realtime, Gemini Live, etc.) for the voice agent.
• Start the agent session for the target LiveKit room.
5) Connect the AvatarSession to the AgentSession
• Start the avatar with the agent session and the room so the avatar worker receives the agent audio output and synchronizes video:
await avatar.start(session, room=ctx.room)
6) Ensure audio is published by the avatar worker (not the agent)
• Disable direct audio publishing from the agent so the avatar worker handles synchronized A/V output:
await session.start(
room=ctx.room,
room_output_options=RoomOutputOptions(audio_enabled=False)
)
7) Frontend consumption
• On the client, use the helper that exposes the avatar worker tracks (e.g., useVoiceAssistant()), then render audioTrack and videoTrack. The avatar worker appears as a participant with lk.publish_on_behalf set to the agent identity.
Notes / options
• Supported realtime models: OpenAI Realtime, Azure OpenAI Realtime, Gemini Live (all compatible with RealtimeModel).
• The avatar plugin automatically receives agent audio output and synchronizes it to the avatar video stream when configured as above.
Would you like a short example wiring together a specific realtime model (OpenAI, Azure, or Gemini) with code for AgentSession + AvatarSession tailored to your stack (Python backend, React frontend, or other)?
Sources: LiveAvatar virtual avatar integration guide | LiveKit docs | bitHuman virtual avatar integration guide | LiveKit Docs | Virtual avatar plugins | LiveKit Docs | OpenAI Realtime API plugin guide | LiveKit docs | Azure OpenAI Realtime API and LiveKit | LiveKit docsicy-beard-64788
12/10/2025, 5:33 PMtall-airline-16756
12/10/2025, 5:33 PMlivekit-agents[liveavatar] and run the AvatarSession + AgentSession code on your backend service (typically Python). This code authenticates with LiveAvatar, starts the agent session, and calls avatar.start(session, room=...).
• Environment variables / keys: put LIVEAVATAR_API_KEY (and any realtime model keys) in your backend environment or .env file.
• Room control and server-side logic: creating/joining LiveKit rooms, starting/stopping agent sessions, and setting RoomOutputOptions(audio_enabled=False) all happen on the backend.
Avatar worker & voice sync (backend)
• The avatar worker runs as part of the avatar plugin on your server. It receives the agent audio output and publishes synchronized audio+video into the LiveKit room.
Frontend (where you render avatar A/V)
• Client subscribes to LiveKit participants/tracks. Use a helper like useVoiceAssistant() (React) to get the avatar worker’s audioTrack and videoTrack and attach them to your <audio>/<video> or player.
• No avatar plugin code runs in the browser — the frontend only renders tracks the backend/avatar worker publishes.
Quick checklist to get unstuck
1. Tell me your stack (Python/Node + React/vanilla).
2. Confirm you have: LiveAvatar API key, realtime model credentials, and LiveKit server/room ready.
3. I can then give a minimal backend code snippet (Python) and the matching frontend snippet for rendering the avatar audio/video.
Which stack should I prepare the example for?icy-beard-64788
12/11/2025, 5:12 AMtall-airline-16756
12/11/2025, 5:13 AMroomJoin, plus publish/subscribe permissions as needed) so it can receive user audio and publish synthesized speech.
What to do next (quick checklist)
1. Generate a token for the voice agent on your server with the agent identity and room name.
2. Give it grants matching what the agent must do (subscribe to user audio, publish the synthesized audio/video if applicable).
3. Use that token when the agent process/worker connects to the LiveKit room.
If you want, tell me which server language you use (Python/Node/etc.) and I’ll give the minimal token-generation example and the typical grants to include.
Sources: Authentication | LiveKit docs | OpenAI and LiveKit partner to turn Advanced Voice into an API | OpenAI and LiveKit partner to turn Advanced Voice into an API | Agent dispatch | LiveKit docs | Generating tokens | LiveKit docsicy-beard-64788
12/11/2025, 5:18 AMtall-airline-16756
12/11/2025, 5:19 AMroomJoin: true and publish/subscribe as needed (subscribe to user audio, publish synthesized audio). Use the same room name.
2) Start the AgentSession (backend)
• Use your realtime voice model to produce audio output inside the AgentSession.
• When starting the agent session, pass RoomOutputOptions(audio_enabled=False) so the agent does not publish audio directly to the room (the avatar worker will publish the synchronized audio/video).
3) Start the AvatarSession and attach it to the AgentSession (backend)
• Create an AvatarSession(avatar_id="your_avatar_id").
• Start the avatar with the agent session and the room:
# conceptual
await avatar.start(agent_session, room=room)
This ensures the avatar worker receives the agent's audio output and publishes synchronized audio+video into the LiveKit room.
4) Have the agent join the LiveKit room with its token (worker/agent process)
• Use the agent token when the agent process connects as a participant so LiveKit recognizes it separately from the user and avatar.
5) Frontend: subscribe to the avatar worker tracks
• On the client, subscribe to participants and identify the avatar worker (it will have lk.publish_on_behalf set to the agent identity).
• Use helpers like useVoiceAssistant() to get the audioTrack and videoTrack published by the avatar worker, and attach them to your audio/video elements.
Checklist to confirm
• You have a third token for the agent.
• AgentSession is producing audio from a supported RealtimeModel.
• You call avatar.start(agent_session, room=...).
• AgentSession RoomOutputOptions has audio_enabled=False.
• Agent process connects with its token so the avatar worker can publish on its behalf.
Tell me your backend language (Python or Node) and I’ll give the minimal code snippets for token generation, AgentSession start, and AvatarSession wiring.icy-beard-64788
12/11/2025, 5:26 AMtall-airline-16756
12/11/2025, 5:26 AMavatar.start(session, room)) and React (subscribe to avatar worker tracks with LiveKit React and render audio/video).icy-beard-64788
12/11/2025, 5:27 AMtall-airline-16756
12/11/2025, 5:28 AMavatar.start(agentSession, room).
If Nova Sonic has only REST (non-streaming):
• You can poll/trigger synthesis for utterances, buffer the returned audio, and play/stream it into the avatar worker in near-real-time—but latency will be higher.
Next step I can take for you
• If you confirm Nova Sonic’s API type and that you have a persistent Node process to act as the agent, I’ll provide a minimal Node example that:
a. Generates the agent token (you already have token generation for users/avatar; I’ll show the agent variant).
b. Creates/starts an AgentSession (generic placeholder) that accepts audio from Nova Sonic streaming or REST.
c. Starts AvatarSession with the AgentSession and room.
d. Shows the React snippet to subscribe/render the avatar audio/video.
Which Nova Sonic API type is available and can your backend open persistent connections?