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);

Constructors

Methods

Constructors

  • Creates a new AvatarSession.

    Parameters

    Returns AvatarSession

    Throws

    LemonSliceException if invalid agentId or agentImageUrl is provided, or if LemonSlice API key is not set

Methods

  • 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<void>

    Throws

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