How to Add a LiveKit AI Avatar to Your Voice Agent

Add a photoreal LiveKit AI avatar to your LiveKit Agents voice agent with the SpatialReal avatar plugin: a few lines of Python, rendered on web, iOS and Android.

By the SpatialReal team4 min read

A SpatialReal avatar joining a LiveKit voice agent

If you've built a voice agent on LiveKit Agents, you already have the hard parts: speech-to-text, a language model, text-to-speech, turn detection and a room your users join. What it doesn't have is a face. The SpatialReal LiveKit avatar plugin adds a LiveKit AI avatar to it: a photorealistic SpatialReal avatar joins your LiveKit room as another participant and speaks whatever your agent says — lip-sync, expressions and interruptions included. Your agent's logic doesn't change.

Key takeaways

  • The SpatialReal plugin adds a photoreal avatar to a LiveKit Agents voice agent in a few lines of Python.
  • The avatar joins your LiveKit room as a participant; your web, iOS or Android client renders it on the device.
  • It works with speech-to-text, language model and text-to-speech pipelines and with realtime models, and stops when the user interrupts.

How the SpatialReal LiveKit avatar plugin works

The avatar becomes one more participant in your room, next to your agent and your user:

Diagram: your LiveKit agent sends speech to SpatialReal, which publishes the avatar into your LiveKit room for the client to render
How the SpatialReal avatar joins your LiveKit room.
  1. Your agent works as it does today. It hears the user in the room and produces a reply. The plugin takes the reply's speech and sends it to SpatialReal.
  2. SpatialReal publishes the avatar into your room — its speech and motion — as a participant.
  3. Your client joins the room and renders the avatar. A web page, an iOS app or an Android app sends the user's microphone and draws the avatar on the device.

The plugin also handles turns and interruption: when the user talks over the avatar, it stops.

Because SpatialReal sends the avatar's motion rather than video, your client renders the avatar itself, at the screen's own resolution, using around 10–15 KB/s instead of a video stream's 1–2 MB/s. More on why in On-device vs cloud video avatars.

What you need

  • A working LiveKit Agents voice agent in Python
  • Your LiveKit URL, API key and API secret
  • A SpatialReal App ID, API key and avatar ID — create them for free in SpatialReal Studio and pick an avatar from the library

Step 1: Install the LiveKit avatar plugin

pip install livekit-plugins-spatialreal

Step 2: Configure it

The plugin reads its settings from the environment:

Variable Description
SPATIALREAL_API_KEY Your SpatialReal API key
SPATIALREAL_APP_ID Your SpatialReal App ID
SPATIALREAL_AVATAR_ID The avatar to use
LIVEKIT_URL Your LiveKit server URL
LIVEKIT_API_KEY Your LiveKit API key
LIVEKIT_API_SECRET Your LiveKit API secret

Step 3: Start the avatar with your agent session

Create an avatar session and start it with your agent session and room — before you start the agent session:

from livekit.agents import AgentSession, JobContext, WorkerOptions, cli
from livekit.plugins import spatialreal


async def entrypoint(ctx: JobContext):
    await ctx.connect()

    # your existing pipeline
    session = AgentSession(vad=vad, stt=stt, llm=llm, tts=tts)

    # the avatar joins the room
    avatar = spatialreal.AvatarSession()
    await avatar.start(session, room=ctx.room)

    await session.start(agent=YourAgent(), room=ctx.room)


if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))

That's the whole change to your agent: your LiveKit Agents avatar is live. From now on, whatever it says is spoken by the avatar. The plugin works with a speech-to-text → language model → text-to-speech pipeline, and with a realtime model.

Run it as usual:

python agent.py dev

When a user joins the room, the avatar joins too, publishing its audio and motion.

Step 4: Render the avatar with the SpatialReal SDK

Your client joins the same room and renders the avatar with a SpatialReal SDK. You'll need a small token endpoint on your server that hands the client a LiveKit room token and a SpatialReal session token. There are step-by-step guides for each platform:

Run the complete SpatialReal + LiveKit example

If you'd rather start from working code, the SpatialReal examples repository has an agent and three clients — web, iOS and Android:

git clone https://github.com/SpatialReal-ai/spatialreal-examples.git
cd spatialreal-examples/avatar-integration/livekit

Copy .env.example to .env in both agent/ and web-client/, fill in your values, then run each in its own terminal:

cd agent && uv run agent.py dev
cd web-client && npm install && npm run dev

FAQ

How do I add a LiveKit AI avatar to my voice agent? Install the SpatialReal LiveKit avatar plugin, start a spatialreal.AvatarSession() before your agent session, and render the avatar in your client with a SpatialReal SDK.

Does SpatialReal work with LiveKit Agents? Yes. Install livekit-plugins-spatialreal, start a spatialreal.AvatarSession() with your agent session, and the SpatialReal avatar joins your LiveKit room as a participant.

Does the SpatialReal plugin work with realtime models? Yes. It works with a speech-to-text → language model → text-to-speech pipeline and with a realtime model.

What happens when the user interrupts the SpatialReal avatar? The SpatialReal plugin handles turns and interruption: when the user talks over the avatar, it stops.

Which clients can render a SpatialReal avatar from a LiveKit room? Web pages, iOS apps and Android apps, using the SpatialReal Web, iOS and Android SDKs.

Next steps

Build your first AI avatar agent

Describe an agent in SpatialReal Studio and share it as a link, or give your own voice agent a photoreal face with the SDK. Creating an account is free.

About SpatialReal

SpatialReal builds real-time AI avatar agents: photorealistic avatars that talk in real time, rendered on the viewer's own device. Teams use SpatialReal Agent to launch a fully managed avatar agent from a description, or SpatialReal Avatar Integration to give their own voice agent a face — with SDKs for Web, iOS and Android and a plugin for LiveKit Agents. SpatialReal is a member of the NVIDIA Inception program.