Skip to main content

Step 1 — Install and configure

pip install livekit-agenthuman
Set your environment variables:
AGENTHUMAN_API_KEY=ah_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
AGENTHUMAN_AVATAR=avat_xxxxxxxxxxxxxxxxxxxxxxxx   # optional default avatar
LIVEKIT_URL=wss://your-project.livekit.cloud
LIVEKIT_API_KEY=your-livekit-key
LIVEKIT_API_SECRET=your-livekit-secret

Step 2 — Add AvatarSession to your agent

Import AvatarSession, instantiate it with your avatar, and call start() before starting the agent session:
import agenthuman
from livekit.agents import Agent, AgentServer, AgentSession, JobContext

server = AgentServer()

@server.rtc_session()
async def entrypoint(ctx: JobContext):
    session = AgentSession(
        # ... your STT, LLM, TTS config
    )

    avatar = agenthuman.AvatarSession(
        avatar="avat_xxxxxxxxxxxxxxxxxxxxxxxx",
        aspect_ratio="4:3"
    )
    await avatar.start(session, room=ctx.room)

    await session.start(
        agent=Agent(instructions="You are a helpful assistant."),
        room=ctx.room
    )
That’s it. AvatarSession creates the Agent Human session, generates the LiveKit token, and routes your agent’s audio output through the avatar video stream automatically.

Step 3 — Run your agent

python agent.py start
avatar.start() reads LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET from environment variables. You can also pass them directly — see Configuration.