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

# Pipecat Integration

> Connect to a LemonSlice Avatar via the Pipecat agent framework

## Overview

LemonSlice integrates with [Pipecat](https://www.pipecat.ai/), an open-source framework for building multimodal conversational agents by Daily. The `LemonSliceTransport` object connects your Pipecat app to a LemonSlice avatar for real-time voice conversations with synchronized video.

<Note>
  Jump to the [starter projects](#starter-projects) section for ready-to-use repos. For production UI patterns (avatar readiness, error handling, timeouts), see [Production checklist](/reference/production-checklist).
</Note>

## Prerequisites

Before integrating LemonSlice with Pipecat, ensure you have the following:

1. 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](https://lemonslice.com/agents)

     <Note>Selected voices and personalities for a LemonSlice avatar preset are ignored when using the Pipecat plugin.</Note>

2. Pipecat Python Application
   * Either your own existing application, or follow the [Pipecat quickstart](https://docs.pipecat.ai/getting-started/quickstart) to create one.

## How to use

<Steps>
  <Step title="Install the plugin">
    Within your Pipecat app, install the LemonSlice transport:

    ```shell SHELL theme={null}
    pip install "pipecat-ai[lemonslice]"
    ```
  </Step>

  <Step title="Authenticate">
    1. Create a [LemonSlice API key](https://lemonslice.com/agents/api)
    2. In your Pipecat app, set `LEMONSLICE_API_KEY` in your .env file
  </Step>

  <Step title="Create the LemonSlice transport layer">
    Create an instance of `LemonSliceTransport` by providing your bot name, LemonSlice API key, session request, and additional parameters.

    ```python PYTHON theme={null}
    import os
    import aiohttp
    from pipecat.transports.lemonslice.transport import (
        LemonSliceNewSessionRequest,
        LemonSliceParams,
        LemonSliceTransport,
    )

    async def main():
        async with aiohttp.ClientSession() as session:
            transport = LemonSliceTransport(
                bot_name="Pipecat",
                api_key=os.getenv("LEMONSLICE_API_KEY"),
                session=session,
                session_request=LemonSliceNewSessionRequest(
                    agent_image_url="...",
                ),
            )

            # stt, tts, llm...
    ```

    Parameters for `LemonSliceTransport`:

    | Parameter         | Description                                                           |
    | ----------------- | --------------------------------------------------------------------- |
    | `bot_name`        | The name of the Pipecat bot instance.                                 |
    | `api_key`         | LemonSlice API key for authentication.                                |
    | `session`         | An `aiohttp.ClientSession` for making async HTTP requests.            |
    | `session_request` | Session creation parameters. See `LemonSliceNewSessionRequest` below. |
    | `params`          | *(Optional)* Transport configuration.                                 |

    Parameters for `LemonSliceNewSessionRequest`.

    | Parameter               | Description                                                                                                                                                                                                                                                                                                                                   |
    | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `agent_image_url`       | A URL to an avatar image to use. Provide either agent\_id or agent\_image\_url, not both.                                                                                                                                                                                                                                                     |
    | `agent_id`              | The ID of a LemonSlice avatar preset. Provide either agent\_id or agent\_image\_url, not both.                                                                                                                                                                                                                                                |
    | `agent_prompt`          | *(Optional)* A high-level system prompt that subtly influences the avatar's movements, expressions, and emotional demeanor during the talking state. Defaults to `"a person talking"`.                                                                                                                                                        |
    | `agent_idle_prompt`     | *(Optional)* A high-level system prompt that influences the avatar's movements, expressions, and emotional demeanor during the idle state. Defaults to `"a serious person"`.                                                                                                                                                                  |
    | `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. |
    | `model`                 | *(Optional)* Model variant (`"lite"`, `"flash"`, or `"pro"`). Leave unset to use the normal flagship model.                                                                                                                                                                                                                                   |
    | `aspect_ratio`          | *(Optional)* Output aspect ratio (`"2x3"`, `"9x16"`, or `"1x1"`).                                                                                                                                                                                                                                                                             |
    | `daily_room_url`        | *(Optional)* Daily room URL to use. If not provided, LemonSlice will create a new room at an additional cost of 0.51 credits per participant minute.                                                                                                                                                                                          |
    | `daily_token`           | *(Optional)* Daily token for authenticating with the room.                                                                                                                                                                                                                                                                                    |
    | `lemonslice_properties` | *(Optional)* A dictionary of extra connection properties. See `lemonslice_properties` below.                                                                                                                                                                                                                                                  |

    Parameters for `lemonslice_properties`.

    | Parameter           | Description                                                                                                                                                                                                                                                                                                                            |
    | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `enable_recording`  | Enable [Daily call recording](https://docs.daily.co/guides/products/live-streaming-recording/recording-calls-with-the-daily-api). Must be one of `cloud`, `cloud-audio-only`, `local`, or `raw-tracks`. If set, `recordings_bucket` must also be provided. Enabling recording incurs an additional charge of 0.378 credits per minute. |
    | `recordings_bucket` | The S3 bucket configuration where recordings will be saved. Follows the [Daily recording bucket specification](https://docs.daily.co/guides/products/live-streaming-recording/storing-recordings-in-a-custom-s3-bucket).                                                                                                               |
  </Step>

  <Step title="Insert the LemonSlice transport layer into the pipeline">
    Add the LemonSlice transport layer to your processing pipeline.

    ```python PYTHON {5, 10} theme={null}
            # stt, tts, llm...

            pipeline = Pipeline(
                [
                    transport.input(),
                    stt,
                    user_aggregator,
                    llm,
                    tts,
                    transport.output(),
                    assistant_aggregator,
                ]
            )

            task = PipelineTask(
                pipeline,
                params=PipelineParams(
                    audio_in_sample_rate=16000,
                    audio_out_sample_rate=16000,
                ),
            )
    ```

    <Note>The LemonSlice avatar participant is automatically filtered out from `transport.on_client_connected` and `transport.on_client_disconnected` events. Only human participant connections trigger these event handlers.</Note>
  </Step>
</Steps>

## Implementation Details

* 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.
* The Daily video UI should filter out the Pipecat bot participant from being displayed. This participant only exists to facilitate passing audio between the user, Pipecat, and LemonSlice.

## Starter projects

| Repo                                                                                                                                                 | What's included                                                                                                                                           |
| :--------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`video-avatar-lemonslice-transport.py`](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-lemonslice-transport.py) | Run a Pipecat pipeline locally and join with [Daily Prebuilt](https://www.daily.co/) to quickly test your agent with a LemonSlice avatar.                 |
| [`05-pipecat-app`](https://github.com/lemonsliceai/lemonslice-examples/tree/main/05-pipecat-app)                                                     | Fullstack web app using the `LemonSliceTransport` within Pipecat. Includes LemonSlice-augmented Pipecat pipeline, front-end UI, and backend token server. |

## Additional resources

<Columns cols={2}>
  <Card title="LemonSliceTransport documentation" icon="book-open" href="https://docs.pipecat.ai/server/services/transport/lemonslice" cta="View docs" />
</Columns>
