Skip to main content
Give a face to your Livekit agents with our TruGen Avatars, using our official Livekit Agents plugin.

Get started

1

Install the plugin

Install the TruGen plugin from Livekit registry, using the following command.
uv add "livekit-agents[trugen]~=1.3" # When using UV
pip install "livekit-agents[trugen]~=1.3" # When using PIP
2

Generate an API key

  1. Using TruGen.AI Developer Platform, generate an API key from our developers page.
  2. Set the newly generated API key as TRUGEN_API_KEY environment variable in your .env file.
3

Adding Avatar session to Livekit Agent

  1. To your existing Livekit agent, import the trugen plugin from livekit.plugins.
from livekit.plugins import trugen
  1. Instantiate a new instance of AvatarSession from the trugen plugin and set the avatar id.
avatar_id = os.getenv("TRUGEN_AVATAR_ID") or "45e3f732"
trugen_avatar = trugen.AvatarSession(avatar_id=avatar_id)
  1. Start the trugen_avatar session using the start method, while passing the current agent session and room context.
await trugen_avatar.start(session, room=ctx.room)

Complete Example

from livekit.plugins import trugen

async def entrypoint(ctx: JobContext):
    session = AgentSession(
      # Your existing configuration
    )

    avatar_id = os.getenv("TRUGEN_AVATAR_ID") or "45e3f732"
    trugen_avatar = trugen.AvatarSession(avatar_id=avatar_id)
    await trugen_avatar.start(session, room=ctx.room)

    await session.start(
      # Start agent session as usual
    )
  1. Gracefully shutdown Livekit agent; use ctx.room.disconnect() to close the room connection or use ctx.shutdown() to end the JobContext.
    This step is ensures that your TruGen Avatar session shuts down correctly. We automatically stop the session when the room is disconnected or when the primary participant is disconnected

More Resourcess