Skip to main content

Overview

LiveKit Agents provides a realtime framework for voice, video, and multimodal applications. Our open-source integration lets you add a LemonSlice avatar to your existing agent stack.
Jump to the starter projects section for ready-to-use repos. For production UI patterns (avatar readiness, error handling, timeouts), see Production checklist.

Prerequisites

  1. A LemonSlice account and API key associated with an active subscription. Create a key at lemonslice.com/developers.
  2. A reference image for your avatar. See our guide for recommendations on how to design your avatar image to achieve the best quality possible.
  3. LiveKit Agents app

How to use

1

Install the plugin

Within your LiveKit Agents app, install the plugin:
2

Authenticate

In your LiveKit Agents app, set LEMONSLICE_API_KEY in your .env file.
3

Add AvatarSession to AgentSession

In your LiveKit Agents app, create a lemonslice.AvatarSession alongside your AgentSession:
In the Node.js plugin, session fields that are not first-class AvatarSession options are passed through extraPayload.
When using the Gemini Live S2S model for realtime interactions, set response_done_timeout=0.8 to handle end of responses correctly.If you encounter stutters or glitches with any other TTS, please contact support@lemonslice.com.
4

Hook into Events

Listen to LemonSlice RPC events over the LiveKit data channel to better manage the avatar lifecycle:
LemonSlice Events
These events are available to both your backend agent and frontend client, allowing you to coordinate avatar state across your entire application.
5

Preview

Preview the avatar in the Agents Playground or refer to one of our starter projects for sample frontend code.
6

Shutdown the LiveKit room

Gracefully shut down the LiveKit room, LiveKit agent, and/or LemonSlice avatar session:
  1. Call ctx.room.disconnect() to close the LiveKit room connection which will end the LemonSlice avatar session.
  2. Call ctx.shutdown() to stop the Agent’s JobContext and the LemonSlice avatar session if you don’t want to shutdown the LiveKit room.
  3. Call the session control endpoint with the terminate event to shutdown only the LemonSlice avatar without shutting down the LiveKit room or agent.
where ctx is LiveKit’s agents.JobContext defined by the function annotated with @server.rtc_session()
PYTHON
If the LemonSlice session is not shut down, it will remain active until the configured idle timeout is reached or your session reaches the maximum allowed duration.

Multiple avatars in one room

You can put several LemonSlice avatars in the same LiveKit room. Each avatar needs:
  1. A unique LiveKit participant identity (and preferably a display name)
  2. Its own AgentSession — one session drives one avatar
For the fastest setup time, start the avatars in parallel, then start the agent sessions in parallel (asyncio.gather / Promise.all).
If a value is not provided for the avatar participant identity in the AvatarSession declaration, the default value "lemonslice-avatar-agent" is used. Since two avatars cannot share an identity, concurrent avatars must set this property explicitly. On the frontend, filter by participant identity rather than assuming a single avatar participant.

Deploy on LiveKit Cloud

While you can host your agents on an external Python or Node.js server, we recommend LiveKit Cloud. It reduces setup and provides infrastructure, hosting, and observability out of the box.

Starter projects