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. LemonSlice avatar configuration (either a base image URL or a LemonSlice avatar ID)
    • Agent base image — a publicly accessible image URL of your avatar, focused on the face. The image should be 368 × 560 pixels. LemonSlice will automatically center-crop your image to the target aspect ratio if the dimensions do not match the expected values. Best results are achieved with anthropomorphic images where the face and mouth are clearly identifiable.
    • LemonSlice Agent ID
      Selected voices and personalities for a LemonSlice agent will be ignored when using the LiveKit plugin.
  2. LiveKit Agents app

How to use

1

Install the plugin

  1. Within your LiveKit Agents app, install the plugin:
2

Authenticate

  1. Create a LemonSlice API key
  2. 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, the LemonSlice session will remain active until the configured idle timeout is reached or the 1-hour maximum session duration expires.

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