Overview
LiveKit Agents provides a realtime framework for voice, video, and physical AI agents. Through our open-source integration you can seamlessly add a LemonSlice avatar to real-time voice AI systems.Quick Start
This section includes a basic usage example and some reference material. For links to more detailed documentation, see Additional resources.Prerequisites
-
LemonSlice agent information
Either a base image URL or a LemonSlice Agent 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 LemonSlice LiveKit Agent Python Example, or
- Follow the LiveKit VoiceAI quickstart for Python or Node.js to create one.
Integration Guide
Authenticate
- Create a LemonSlice API key
- In your LiveKit Agents app, set
LEMONSLICE_API_KEYin your .env file
Add AvatarSession to AgentSession
In your LiveKit Agents app, create a Parameters for
lemonslice.AvatarSession alongside your AgentSession:lemonslice.AvatarSession. Either agent_image_url or agent_id is required.| Parameter | Description |
|---|---|
agent_image_url | A URL to an agent image to use. |
agent_id | The ID of the LemonSlice agent. |
agent_prompt | (Optional) A high-level system prompt that subtly influences the avatar’s movements, expressions, and emotional demeanor. This prompt is best used to suggest general affect or demeanor (for example, “feel excited” or “look sad”) rather than precise or deterministic actions. |
agent_idle_prompt | (Optional) A high-level system prompt that influences the avatar’s movements, expressions, and emotional demeanor during the idle state. |
idle_timeout | (Optional) Idle timeout in seconds. Defaults to 60. If a negative number is provided, the session will have no idle timeout. |
response_done_timeout | (Optional) Time in seconds to wait without receiving new audio bytes before marking the response as complete. Some TTS models do not send an end response event, or do not send it in a timely manner, after transmitting all audio bytes. This parameter enables detection of response completion when such events are missing or delayed. |
JavaScript parameters use camelCase. For example:
agent_image_url becomes agentImageUrl.When using the Gemini Live S2S model for realtime interactions, set
response_done_timeout=0.5 to handle end of responses correctly.If you encounter stutters or glitches with any other TTS, please contact support@lemonslice.com.Preview
Preview the avatar in the Agents Playground or a frontend starter app that you build.
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()