> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# LemonSliceTransport

> AI avatar video service for adding LemonSlice avatars to Daily rooms

## Overview

`LemonSliceTransport` enables your Pipecat bot to join the same virtual room as a LemonSlice avatar and human participants. The transport integrates with the [LemonSlice](https://lemonslice.com/) platform to add interactive AI-powered video avatars to Daily rooms. The service handles bidirectional audio streaming, avatar animations, voice activity detection, and conversation interruptions to deliver engaging conversational AI experiences with lifelike visual presence.

When used, the Pipecat bot connects to a Daily room alongside the LemonSlice avatar and user. The bot receives audio input from participants, processes it through your pipeline, and sends TTS audio to the LemonSlice avatar for synchronized video rendering.

## Transport architecture

`LemonSliceTransport` always uses Daily as the underlying WebRTC transport. There is no standalone WebRTC variant. The avatar joins a Daily room, either one you supply via `daily_room_url` or one LemonSlice provisions for you.

**Embedding in a custom UI:** Daily Prebuilt is not required. Use [`@pipecat-ai/client-js`](/api-reference/client/js/overview) or [`@pipecat-ai/client-react`](/api-reference/client/react/overview) to connect to the session and render the avatar participant's video track inside your own modal or component. The Pipecat bot, the LemonSlice avatar, and your custom UI all connect to the same Daily room.

**Combining with other LLM services (e.g. Bedrock AgentCore):** the avatar transport is independent of your LLM choice. Any LLM service that fits in a Pipecat pipeline can drive a `LemonSliceTransport` bot.

<CardGroup cols={2}>
  <Card title="LemonSliceTransport API Reference" icon="code" href="https://reference-server.pipecat.ai/en/latest/api/pipecat.transports.lemonslice.html">
    Pipecat's API methods for LemonSlice video integration
  </Card>

  <Card title="Example Implementation" icon="play" href="https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-lemonslice-transport.py">
    Complete example with interactive avatar
  </Card>

  <Card title="LemonSlice Platform" icon="microphone" href="https://lemonslice.com/">
    Access interactive avatars and API keys
  </Card>
</CardGroup>

## Installation

To use LemonSlice services, install the required dependency:

```bash theme={null}
uv add "pipecat-ai[lemonslice]"
```

## Prerequisites

### LemonSlice Account Setup

Before using LemonSlice video services, you need:

1. **LemonSlice Account**: Sign up at [LemonSlice Platform](https://lemonslice.com/)
2. **API Key**: Generate an API key from your account dashboard
3. **Avatar Selection**: Choose from available interactive avatars or provide your own agent image

### Required Environment Variables

* `LEMONSLICE_API_KEY`: Your LemonSlice API key for authentication

## Configuration

### LemonSliceTransport

<ParamField path="bot_name" type="str" required>
  The name of the Pipecat bot instance.
</ParamField>

<ParamField path="session" type="aiohttp.ClientSession" required>
  An aiohttp session for making async HTTP requests to the LemonSlice API.
</ParamField>

<ParamField path="api_key" type="str" required>
  LemonSlice API key for authentication.
</ParamField>

<ParamField path="session_request" type="LemonSliceNewSessionRequest" default="None">
  Optional session creation parameters. If not provided, a default agent will be
  used. See [LemonSliceNewSessionRequest](#lemonslicenewsessionrequest) below.
</ParamField>

<ParamField path="params" type="LemonSliceParams" default="LemonSliceParams()">
  Transport configuration parameters. See [LemonSliceParams](#lemonsliceparams)
  below.
</ParamField>

<ParamField path="input_name" type="str" default="None">
  Optional name for the input transport processor.
</ParamField>

<ParamField path="output_name" type="str" default="None">
  Optional name for the output transport processor.
</ParamField>

### LemonSliceNewSessionRequest

Configuration for creating a new LemonSlice session.

<ParamField path="agent_image_url" type="str" default="None">
  URL to an agent image. Provide either `agent_id` or `agent_image_url`, not
  both.
</ParamField>

<ParamField path="agent_id" type="str" default="None">
  ID of a LemonSlice agent. Provide either `agent_id` or `agent_image_url`, not
  both. If neither is provided, a default agent will be used.
</ParamField>

<ParamField path="agent_prompt" type="str" default="None">
  A high-level system prompt that subtly influences the avatar's movements,
  expressions, and emotional demeanor.
</ParamField>

<ParamField path="idle_timeout" type="int" default="None">
  Idle timeout in seconds for the session.
</ParamField>

<ParamField path="daily_room_url" type="str" default="None">
  Daily room URL to use for the session. If not provided, LemonSlice will create
  a new room.
</ParamField>

<ParamField path="daily_token" type="str" default="None">
  Daily token for authenticating with the room.
</ParamField>

<ParamField path="lemonslice_properties" type="dict" default="None">
  Additional connection properties to pass to the LemonSlice session.
</ParamField>

<ParamField path="api_url" type="str" default="None">
  Override the LemonSlice API URL endpoint.
</ParamField>

### LemonSliceParams

Inherits from `DailyParams` (which inherits from `TransportParams`) with the
following defaults:

<ParamField path="audio_in_enabled" type="bool" default="True">
  Whether to enable audio input from participants.
</ParamField>

<ParamField path="audio_out_enabled" type="bool" default="True">
  Whether to enable audio output to participants.
</ParamField>

<ParamField path="microphone_out_enabled" type="bool" default="False">
  Whether to enable microphone output track.
</ParamField>

## Usage

LemonSliceTransport creates a three-way conversation between your Pipecat bot, a
LemonSlice avatar, and human participants. The transport manages the LemonSlice
API session and Daily room connectivity automatically.

See the
[complete example](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-lemonslice-transport.py)
for a full implementation including:

* LemonSlice transport configuration with API key and session setup
* Avatar selection and configuration
* Pipeline integration with TTS
* Event handling for participant management

## Event Handlers

LemonSliceTransport provides event handlers for participant connection
lifecycle. Register handlers using the `@event_handler` decorator on the
transport instance.

### Events Summary

| Event                    | Description                                            |
| ------------------------ | ------------------------------------------------------ |
| `on_client_connected`    | Participant (non-avatar) connected to the session      |
| `on_client_disconnected` | Participant (non-avatar) disconnected from the session |
| `on_avatar_connected`    | LemonSlice avatar connected to the session             |
| `on_avatar_disconnected` | LemonSlice avatar disconnected from the session        |

<Note>
  The `on_client_connected` and `on_client_disconnected` events are only
  triggered for human participants. The LemonSlice avatar triggers separate
  `on_avatar_connected` and `on_avatar_disconnected` events.
</Note>

### Connection Lifecycle

#### on\_client\_connected

Fired when a human participant connects to the session. The LemonSlice avatar is
filtered out from this event.

```python theme={null}
@transport.event_handler("on_client_connected")
async def on_client_connected(transport, participant):
    print(f"Client connected: {participant}")
```

**Parameters:**

| Parameter     | Type                  | Description            |
| ------------- | --------------------- | ---------------------- |
| `transport`   | `LemonSliceTransport` | The transport instance |
| `participant` | `Mapping[str, Any]`   | The participant data   |

#### on\_client\_disconnected

Fired when a human participant disconnects from the session.

```python theme={null}
@transport.event_handler("on_client_disconnected")
async def on_client_disconnected(transport, participant):
    print(f"Client disconnected: {participant}")
```

**Parameters:**

| Parameter     | Type                  | Description            |
| ------------- | --------------------- | ---------------------- |
| `transport`   | `LemonSliceTransport` | The transport instance |
| `participant` | `Mapping[str, Any]`   | The participant data   |

#### on\_avatar\_connected

Fired when the LemonSlice avatar connects to the session.

```python theme={null}
@transport.event_handler("on_avatar_connected")
async def on_avatar_connected(transport, participant):
    print(f"Avatar connected: {participant}")
```

**Parameters:**

| Parameter     | Type                  | Description            |
| ------------- | --------------------- | ---------------------- |
| `transport`   | `LemonSliceTransport` | The transport instance |
| `participant` | `Mapping[str, Any]`   | The participant data   |

#### on\_avatar\_disconnected

Fired when the LemonSlice avatar disconnects from the session.

```python theme={null}
@transport.event_handler("on_avatar_disconnected")
async def on_avatar_disconnected(transport, participant, reason):
    print(f"Avatar disconnected: {participant}, reason: {reason}")
```

**Parameters:**

| Parameter     | Type                  | Description                      |
| ------------- | --------------------- | -------------------------------- |
| `transport`   | `LemonSliceTransport` | The transport instance           |
| `participant` | `Mapping[str, Any]`   | The participant data             |
| `reason`      | `str`                 | The reason for the disconnection |

## Notes

* LemonSlice uses Daily as the underlying transport layer, so all Daily features
  and configuration options are available through the inherited `DailyParams`.
* The transport automatically manages interruptions and sends appropriate control
  messages (`interrupt`, `response_started`, `response_finished`) to the
  LemonSlice session.
* The LemonSlice avatar's microphone is automatically muted to prevent audio
  feedback loops.

## Additional Resources

* [Events Overview](/api-reference/server/events/overview) - Overview of all events in
  Pipecat
* [DailyTransport](/api-reference/server/services/transport/daily) - Underlying Daily transport
  documentation
* [TransportParams](/api-reference/server/services/transport/transport-params) - Base transport
  parameters
