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
- A LemonSlice account and API key associated with an active subscription. Create a key at lemonslice.com/developers.
- A reference image for your avatar. See our guide for recommendations on how to design your avatar image to achieve the best quality possible.
- 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
In your LiveKit Agents app, set
LEMONSLICE_API_KEY in your .env file3
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

