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
- 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.
- LiveKit Agents app
- Your own existing application, or
- The ready-to-use LiveKit playground starter project, or
- Follow the LiveKit VoiceAI quickstart for Python or Node.js to create one.
How to use
1
Install the plugin
- Within your LiveKit Agents app, install the plugin:
2
Authenticate
- Create a LemonSlice API key
- In your LiveKit Agents app, set
LEMONSLICE_API_KEYin your .env file
3
Add AvatarSession to AgentSession
In your LiveKit Agents app, create a
lemonslice.AvatarSession alongside your AgentSession:- Python
- Node.js
extraPayload (Node.js)
extraPayload (Node.js)
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:
- Call
ctx.room.disconnect()to close the LiveKit room connection which will end the LemonSlice avatar session. - Call
ctx.shutdown()to stop the Agent’s JobContext and the LemonSlice avatar session if you don’t want to shutdown the LiveKit room. - Call the session control endpoint with the
terminateevent to shutdown only the LemonSlice avatar without shutting down the LiveKit room or agent.
ctx is LiveKit’s agents.JobContext defined by the function annotated with @server.rtc_session()PYTHON

