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

# Pipecat

> Integrate a Tavus Face into your Pipecat application as a participant or a video feed for the bot.

> [!TIP]
>
> We recommend using Tavus’s Full Pipeline in its entirety for the lowest latency and most optimized multimodal experience. Third party integrations only provide rendering, while our Full Pipeline includes perception, turn-taking, and rendering for complete conversational intelligence.

**Pipecat** runs your conversational stack (STT, LLM, TTS, room transport). **Tavus** supplies the **face’s** synchronized video and audio - either as a separate room participant (`TavusTransport`) or as a pipeline layer on the bot (`TavusVideoService`). Pick the pattern that matches whether you want a third participant in the Daily room or only the Pipecat bot visible.

Tavus offers integration with [Pipecat](https://www.pipecat.ai/), an open-source framework for building multimodal conversational agents by Daily. You can integrate Tavus into your Pipecat application in two ways:

* Additional Tavus Participant (`TavusTransport`)
  * The Tavus agent joins as a third participant alongside the Pipecat bot and human user. It receives audio from the Pipecat pipeline’s TTS layer and renders synchronized video and audio.
* Video Layer for Pipecat Bot (`TavusVideoService`)
  * Only the Pipecat bot is present in the room. `TavusVideoService` acts as a pipeline layer, sending TTS audio to Tavus in the background. Tavus returns video and audio streams for the bot to display. No additional participant is added.

## Prerequisites

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

> [!WARNING]
>
> Linux or macOS is required. Windows is currently not supported due to the `daily-python` dependency.

* [**Tavus API Key**](https://maker.tavus.io/dev/api-keys)

* [**Tavus `face_id`**](https://maker.tavus.io/dev/faces)
  * You can use one of [Tavus's stock faces](https://maker.tavus.io/dev/faces) or your own custom face.
  * We recommend using **Phoenix-4.5 [Pro faces](https://docs.tavus.io/sections/faces/stock-faces#pro)**, which are optimized for low-latency, real-time applications.

* **Pipecat Python Application**
  * Either your own existing application, or use Pipecat’s examples:
    * [`TavusTransport`](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-tavus-transport.py)
    * [`TavusVideoService`](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-tavus-video-service.py)

## `TavusTransport`

`TavusTransport` connects your Pipecat app to a Tavus conversation, allowing the bot to join the same virtual room as the **face** participant and other participants. To get started, you can follow the following steps or learn more from this [sample code](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-tavus-transport.py).

### Integration Guide for `TavusTransport`

**1. Step 1: Setup and Authentication**

1. Install the Tavus plugin for Pipecat.

```sh theme={null}
pip install "pipecat-ai[tavus,daily]"
```

2. In the `.env` file of your pipecat application (at `/path/to/pipecat/.env`) add:

```env theme={null}
TAVUS_API_KEY=<api-key>
TAVUS_FACE_ID=<your_face_id>
```

> [!NOTE]
>
> * Replace `<api-key>` with your actual Tavus API key. You can generate one in the [PAL Maker](https://maker.tavus.io/dev/api-keys). See [Authentication](https://docs.tavus.io/api-reference/authentication.md) for how Tavus APIs use `x-api-key`. `TavusTransport` joins a Tavus-backed conversation; create sessions with [Create Conversation](https://docs.tavus.io/api-reference/conversations/create-conversation.md) when your app provisions them via the API.
>
> * Replace `<your_face_id>` with the Face ID you want to use.

**2. Step 2: Create the Tavus transport layer**

Create an instance of `TavusTransport` by providing your bot name, Tavus API key, Face ID, session, and additional parameters.

```py {6, 17-28} theme={null}
import os
import sys
import aiohttp
from dotenv import load_dotenv
from loguru import logger
from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.transports.services.tavus import TavusParams, TavusTransport
# Other imports...

load_dotenv(override=True)

logger.remove(0)
logger.add(sys.stderr, level="DEBUG")

async def main():
    async with aiohttp.ClientSession() as session:
        transport = TavusTransport(
            bot_name="Pipecat bot",
            api_key=os.getenv("TAVUS_API_KEY"),
            face_id=os.getenv("TAVUS_FACE_ID"),
            session=session,
            params=TavusParams(
                audio_in_enabled=True,
                audio_out_enabled=True,
                microphone_out_enabled=False,
                vad_analyzer=SileroVADAnalyzer(),
            ),
        )

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

> [!NOTE]
>
> See [Pipecat API Reference](https://pipecat-docs.readthedocs.io/en/latest/api/pipecat.transports.services.tavus.html#tavus) for the configuration details.

**3. Step 3: Insert the Tavus transport layer into the pipeline**

Add the Tavus transport layer to your processing pipeline.

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

        pipeline = Pipeline(
            [
                transport.input(),  # Transport user input
                stt,  # STT
                context_aggregator.user(),  # User responses
                llm,  # LLM
                tts,  # TTS
                transport.output(),  # Transport bot output
                context_aggregator.assistant(),  # Assistant spoken responses
            ]
        )
```

**4. Step 4: Run the program**

1. Run the following command to execute the program:

```sh theme={null}
python <file-name>.py
```

> [!NOTE]
>
> Replace the `<file-name>` with your actual Python filename.

2. Use the **Tavus Daily URL** provided in the console to interact with the agent.

## `TavusVideoService`

You can use `TavusVideoService` to enable real-time AI-driven video interactions in your Pipecat app. To get started, you can follow the following steps or refer to this [sample code](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-tavus-video-service.py).

### Integration Guide for `TavusVideoService`

**1. Step 1: Setup and Authentication**

1. Install the Tavus plugin for Pipecat.

```sh theme={null}
pip install "pipecat-ai[tavus,daily]"
```

2. In the `.env` file of your pipecat application (at `/path/to/pipecat/.env`) add:

```env theme={null}
TAVUS_API_KEY=<api-key>
TAVUS_FACE_ID=<your_face_id>
```

> [!NOTE]
>
> * Replace `<api-key>` with your actual Tavus API key. You can generate one in the [PAL Maker](https://maker.tavus.io/dev/api-keys). See [Authentication](https://docs.tavus.io/api-reference/authentication.md) for how Tavus APIs use `x-api-key`.
>
> * Replace `<your_face_id>` with the Face ID you want to use.

**2. Step 2: Create the Tavus Video Service**

Create an instance of `TavusVideoService` by providing your Tavus API key and Tavus Face ID.

```py {6, 15-19} theme={null}
import argparse
import os
import aiohttp
from dotenv import load_dotenv
from loguru import logger
from pipecat.services.tavus.video import TavusVideoService
from pipecat.transports.base_transport import BaseTransport
# Other imports...

load_dotenv(override=True)

async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool):
    logger.info(f"Starting bot")
    async with aiohttp.ClientSession() as session:
        tavus = TavusVideoService(
            api_key=os.getenv("TAVUS_API_KEY"),
            face_id=os.getenv("TAVUS_FACE_ID"),
            session=session,
        )

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

> [!NOTE]
>
> See [Pipecat Tavus Service](https://docs.pipecat.ai/server/services/video/tavus) for the configuration details.

**3. Step 3: Insert the Tavus Video Service into the timeline**

Insert the `TavusVideoService` into the pipeline by adding the `tavus` service after the TTS processor in the pipeline.

```py {10} theme={null}
        # stt, tts, llm...

        pipeline = Pipeline(
            [
                transport.input(),  # Transport user input
                stt,  # STT
                context_aggregator.user(),  # User responses
                llm,  # LLM
                tts,  # TTS
                tavus,  # Tavus output layer
                transport.output(),  # Transport bot output
                context_aggregator.assistant(),  # Assistant spoken responses
            ]
        )
```

**4. Step 4: Run the program**

1. Run the following command to execute the program:

```sh theme={null}
python <file-name>.py
```

> [!NOTE]
>
> Replace the `<file-name>` with your actual Python filename.

2. Use the **localhost URL** provided in the console to interact with the agent.

## Advanced: Avatar Emotions

This section is optional. The integrations above work without it.

The Tavus PAL can visually express an emotion while it speaks. With Pipecat's expressive conversation enabled, the LLM tags its replies with a delivery such as `<<warm>>`, the TTS performs it, and `TavusTransport` and `TavusVideoService` set the PAL's emotion to match, timed to when the words are heard. The PAL shows the emotion until the delivery changes.

Supported emotions: `neutral`, `happiness`, `sadness`, `anger`, `fear`, `surprise`, `disgust`, `contempt`.

Enable expressive conversation in your `PipelineParams`:

```py theme={null}
from pipecat.pipeline.worker import PipelineParams, PipelineWorker

worker = PipelineWorker(
    pipeline,
    params=PipelineParams(
        enable_expressive_conversation=True,
    ),
)
```

> [!NOTE]
>
> Requires `pipecat-ai` 1.15.0 or later. Pipecat sends a [`conversation.set_emotion`](https://docs.tavus.io/sections/event-schemas/conversation-set-emotion) interaction to the avatar each time the emotion changes. See the [`TavusVideoService`](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-tavus-video-service.py) and [`TavusTransport`](https://github.com/pipecat-ai/pipecat/blob/main/examples/video-avatar/video-avatar-tavus-transport.py) examples for a complete setup.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.