i
hi
t
Thanks for reaching out, Raj. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — how can I help today? What are you trying to do with LiveKit (e.g., join a room, set up a server, fix a connection/error)?
i
how do i integrate realtime voice agent model which will provide synchronise audio to liveavatar avatar
t
You're asking how to integrate a real-time voice agent model so its audio is synchronized to a LiveAvatar avatar. Below are concise steps you can follow and the key options to configure. 1) Install the LiveAvatar plugin • Add the plugin: uv add "livekit-agents[liveavatar]~=1.3.6" 2) Set your LiveAvatar API key • Put your API key in your environment: LIVEAVATAR_API_KEY=your_liveavatar_api_key 3) Create an AvatarSession for your avatar • Instantiate with your LiveAvatar avatar ID:
Copy code
from 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:
Copy code
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:
Copy code
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 docs
i
where do i do this setup im confused
t
You're right to ask — here's a simple split of where each step happens and what you'll edit. Which stack are you using (Python backend + React frontend, Node backend, or something else)? Backend (where most setup happens) • Install plugin and run server code: install
livekit-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?
i
currently for room creation and participant token im generating 2 token one for avatar and another for real user now do i need another token for voice agent to join the meeting?
t
You're right to ask — yes, you need a separate (third) token for the voice agent. Why: • Every participant joining a LiveKit room needs its own access token (identity, grants, room). The real user, the avatar participant, and the voice agent are each separate participants, so each must authenticate with a distinct token. • The agent's token should include the appropriate video/audio grants (e.g.,
roomJoin
, 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 docs
i
so currently i have token generation and livkit session creation, session start , session stop and keep alive now question is for that livkit room how do i make the agent join and sync audio with liveavatar
t
You're already close — below are the concrete steps to make the voice agent join the LiveKit room and have its audio synchronized by the LiveAvatar avatar. Tell me which language (Python or Node) and frontend stack you use if you want a runnable snippet. 1) Create a token for the voice agent • Generate a third token with the agent identity and grants:
roomJoin: 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:
Copy code
# 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.
i
im using react and using lickit react component and node im using for securely generating the room tokens and all but not sure how i integrate realtime model like nova sonic into this
t
Great — I'll outline a concise Node backend + React frontend plan that integrates a realtime voice model (Nova Sonic) with LiveKit + LiveAvatar so the agent joins the room and the avatar publishes synchronized audio/video. Before I give code, quick confirmations: 1. Do you have a Nova Sonic realtime client/library available on your backend? 2. Do you want the Node examples (token generation + AgentSession/AvatarSession) and React snippets for consuming the avatar tracks? If yes, I’ll provide minimal runnable examples for Node (token creation, starting AgentSession with Nova Sonic audio, creating AvatarSession and calling
avatar.start(session, room)
) and React (subscribe to avatar worker tracks with LiveKit React and render audio/video).
i
no nova soncu client library token generation i have for joining room but agent session and avatar session im not sure what do u mean by that for like i have liveavatar create session api in node backend
t
Thanks — I'll keep this focused. First, quick clarifying questions so I give the exact Node + React code you need: 1. Does Nova Sonic expose a streaming HTTP/WebSocket API (you can push audio chunks and receive synthesized audio) or is it only a REST (non-streaming) endpoint? 2. Do you control a long-running backend process that can open persistent connections (WebSocket/process worker) to act as the agent participant? 3. Can you share which LiveAvatar “create session” API call you already have (endpoint name or a short snippet)? I need to know if it returns an avatar session object you can start from Node. Short explanation of the pieces and how they connect (so you know what to expect) • Agent participant (third token): a backend process connects to LiveKit using its own token and acts as the voice agent. It runs the realtime voice model (or forwards audio to/from Nova Sonic) and exposes the agent audio output to the AvatarSession. • AvatarSession: the LiveAvatar server-side plugin/session that you already create in Node. When you start it with the AgentSession and target LiveKit room, the avatar worker receives the agent audio and publishes synchronized audio+video into the room. • RoomOutputOptions(audio_enabled=False): ensure the agent does not publish audio directly; the avatar worker will publish synced audio/video. If Nova Sonic has a streaming API: • Your Node agent process should open a streaming connection to Nova Sonic, send user audio, and receive synthesized audio in real time. • Feed that synthesized audio into the AgentSession audio output (or into a local audio pipeline the AvatarSession reads) and then call
avatar.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?