Skip to main content

LemonSlice virtual avatar integration guide

How to use the LemonSlice virtual avatar plugin for LiveKit Agents.

Available in
Python

Overview

LemonSlice provides lifelike realtime avatars that naturally interact with users. You can use the open source LemonSlice integration for LiveKit Agents to seamlessly add virtual avatars to your voice AI app.

Quick reference

This section includes a basic usage example and some reference material. For links to more detailed documentation, see Additional resources.

Installation

Install the plugin from PyPI:

uv add "livekit-plugins-lemonslice~=1.3"

Authentication

The LemonSlice plugin requires a LemonSlice API key.

Set LEMONSLICE_API_KEY in your .env file.

Avatar setup

The LemonSlice plugin requires either a base image set by agent_image_url or an agent ID set by agent_id to start an avatar session. Only one of these parameters can be configured.

Agent Image URL

The LemonSlice plugin accepts a source image URL from which to generate the avatar. The avatars render as 368x560 pixel videos. LemonSlice will automatically center-crop your image to the target aspect ratio if the dimensions do not match the expected values. LemonSlice supports a wide range of faces, from humanoid to animal, and styles from photorealistic to animated. Best results are achieved with anthropomorphic images where the face and mouth are clearly identifiable. The image URL must be publicly accessible and return an image/* content type.

Agent ID

To use an existing LemonSlice agent as your avatar, set the agent_id in AvatarSession. You can find the agent ID in the LemonSlice agent dashboard. You can also create new LemonSlice agents through the agent creation flow by specifying an image.

Note

LiveKit TTS settings will supersede selected voices and personalities configured for the LemonSlice agent.

Usage

Use the plugin in an AgentSession. For example, you can use this avatar in the Voice AI quickstart.

from livekit import agents
from livekit.agents import AgentServer, AgentSession
from livekit.plugins import lemonslice
server = AgentServer()
@server.rtc_session()
async def my_agent(ctx: agents.JobContext):
session = AgentSession(
# ... stt, llm, tts, etc.
)
avatar = lemonslice.AvatarSession(
# Publicly accessible image URL for the avatar
agent_image_url="...",
# Prompt to guide the avatar's movements
agent_prompt="Be expressive in your movements and use your hands while talking."
)
# Start the avatar and wait for it to join
await avatar.start(session, room=ctx.room)
# Start your agent session with the user
await session.start(
# ... room, agent, room_options, etc....
)

Preview the avatar in the Agents Playground or a frontend starter app that you build.

Parameters

This section describes some of the available parameters. See the plugin reference for a complete list of all available parameters.

agent_image_urlstringOptional

Publicly accessible image url for the avatar. See Agent Image Setup for details.

agent_idstringOptional

The ID of the LemonSlice agent to use. See Agent ID Setup for details.

agent_promptstringOptional

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 behavior (e.g., "feel excited" or "look sad") rather than precise or deterministic actions.

idle_timeoutintOptional

Idle timeout in seconds. The avatar will leave the session if this timeout is hit. Defaults to 60 seconds. If a negative number is provided, the session will have no idle timeout.

Additional resources

The following resources provide more information about using LemonSlice with LiveKit Agents.