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

# Pipecat

> Voice and multi-modal agents with official Cartesia TTS/STT services

<Frame>
  <img src="https://mintcdn.com/cartesia-2650f86a/GOsvXpql8JfAlgjy/assets/images/pipecat.png?fit=max&auto=format&n=GOsvXpql8JfAlgjy&q=85&s=0b4569efdc203a006b16fdac1a523823" alt="Pipecat logo" width="1169" height="340" data-path="assets/images/pipecat.png" />
</Frame>

## Overview

[Pipecat](https://www.pipecat.ai/) is an open-source Python framework for realtime voice agents.

**Cartesia** is available as a first-party provider plugin for **[TTS and STT services](https://github.com/pipecat-ai/pipecat/tree/main/src/pipecat/services/cartesia)** in the Pipecat repo.

## Prerequisites

Pipecat’s examples require a recent Python installation (see the Pipecat repo's [root-level README](https://github.com/pipecat-ai/pipecat/tree/main#prerequisites) for current prerequisites).

Install the **`pipecat-ai`** Python package with the **`cartesia`** extra for TTS/STT (bracket syntax):

```
pip install "pipecat-ai[cartesia]"
```

You'd also need to choose the **transport** extras your sample needs - you can do this by matching whatever the upstream README lists for that example.

## Getting Started

Integrating Cartesia is as simple as importing Cartesia services and plugging them into your agent:

<Note>
  `CartesiaTurnsSTTService` requires `pipecat-ai[cartesia]>=1.3.0`.\
  We strongly recommend it over the older `CartesiaSTTService` for improved turn detection.
</Note>

```python theme={null}
from pipecat.services.cartesia.tts import CartesiaTTSService
from pipecat.services.cartesia.turns.stt import CartesiaTurnsSTTService

stt = CartesiaTurnsSTTService(
    api_key=os.environ.get("CARTESIA_API_KEY"),
)

tts = CartesiaTTSService(
    api_key=os.environ.get("CARTESIA_API_KEY"),
)

# add cartesia stt and tts to your existing pipeline
pipeline = Pipeline(
    [
        transport.input(),
        stt,
        user_aggregator,
        llm,
        tts,
        transport.output(),
        assistant_aggregator,
    ]
)
```

## Basic Example

Check out [/examples/voice/voice-cartesia-turns.py](https://github.com/pipecat-ai/pipecat/blob/84a50f09583c7de8fe6c42640e275cf2d64db988/examples/voice/voice-cartesia-turns.py) in the `pipecat-ai/pipecat` repo for a fully working voice agent.

```bash theme={null}
# clone and setup pipecat-ai/pipecat
git clone git@github.com:pipecat-ai/pipecat.git
cd pipecat
uv sync

# run with required API keys:
# - CARTESIA_API_KEY
# - OPENAI_API_KEY
uv run examples/voice/voice-cartesia-turns.py
```

## Advanced Example

You can take advantage of Ink's `turn.eager_end` events to start generating an agent response slightly earlier than normal.
This can cut around half a second off your latency, making your agent more human-like.

<Card title="Speculative User Aggregator" icon="github" href="https://github.com/pipecat-ai/pipecat-examples/tree/a5349aeb01bd145593968a0fd45a79dbd6b62a07/speculative-user-aggregator">
  How to use `on_turn_eager_end` from `CartesiaTurnsSTTService`
</Card>
