AvatarSession
Constructor Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
avatar | string | No | Avatar ID or image URL. Falls back to AGENTHUMAN_AVATAR env var, then a default avatar |
aspect_ratio | string | No | Video aspect ratio: '4:3', '3:4' or '1:1'. Defaults to '4:3' |
api_key | string | No | Agent Human API key. Falls back to AGENTHUMAN_API_KEY env var |
avatar_participant_identity | string | No | LiveKit identity for the avatar participant (default: 'agenthuman-avatar-agent') |
avatar_participant_name | string | No | LiveKit display name for the avatar participant (default: 'agenthuman-avatar-agent') |
start() Method
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_session | AgentSession | Yes | The active LiveKit AgentSession |
room | rtc.Room | Yes | The LiveKit room from ctx.room |
livekit_url | string | No | Override for LIVEKIT_URL |
livekit_api_key | string | No | Override for LIVEKIT_API_KEY |
livekit_api_secret | string | No | Override for LIVEKIT_API_SECRET |
start() generates a LiveKit token for the avatar, creates the Agent Human session, and attaches the avatar’s audio output to the room. It must be called before session.start().
session.state Events
The Agent Human server sends status updates to the room as LiveKit data packets on the session.state topic. You can listen for them on ctx.room:
Payload Fields
| Field | Type | Description |
|---|---|---|
state | string | Current avatar state (e.g. "connected", "disconnected") |
reason | string | Optional reason string, present when state changes due to an error or explicit action |