A LemonSlice avatar session.

This class manages the connection between a LiveKit agent and a LemonSlice avatar, routing agent audio output to the avatar for visual representation.

Example

// Using an agent ID
const avatar = new AvatarSession({
agentId: 'your-agent-id',
apiKey: 'your-lemonslice-api-key',
});
await avatar.start(agentSession, room);

// Using a custom avatar image
const avatar = new AvatarSession({
agentImageUrl: 'your-image-url',
apiKey: 'your-lemonslice-api-key',
});
await avatar.start(agentSession, room);

Hierarchy (view full)

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Release any resources owned by this avatar session. Default implementation is a no-op; subclasses can override to perform cleanup.

    Returns Promise<void>

  • Starts the avatar session and connects it to the agent.

    This method:

    1. Creates a LiveKit token for the avatar participant
    2. Calls the LemonSlice API to start the avatar session
    3. Configures the agent's audio output to stream to the avatar

    Parameters

    • agentSession: AgentSession<unknown>

      The agent session to connect to the avatar

    • room: Room

      The LiveKit room where the avatar will join

    • options: StartOptions = {}

      Optional LiveKit credentials (falls back to environment variables)

    Returns Promise<string>

    The session ID of the LemonSlice session

    Throws

    LemonSliceException if LiveKit credentials are not available or if the avatar session fails to start