> ## 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.

# Together AI Text-to-Speech

> TogetherTTSService streams real-time TTS over Together AI's WebSocket API with configurable voice and model options.

## Overview

`TogetherTTSService` provides real-time text-to-speech using Together AI's WebSocket API. It supports streaming synthesis with configurable voice and model options, interruption handling, and automatic reconnection.

> [card] [Together AI TTS API Reference](https://reference-server.pipecat.ai/en/latest/api/pipecat.services.together.tts.html)
>
> Pipecat's API methods for Together AI TTS

> [card] [Example Implementation](https://github.com/pipecat-ai/pipecat/blob/main/examples/voice/voice-together.py)
>
> Complete voice bot example

> [card] [Together AI Documentation](https://docs.together.ai/reference/audio-speech-websocket)
>
> Official Together AI TTS WebSocket API documentation

> [card] [Together AI Platform](https://together.ai/)
>
> Access models and manage API keys

## Installation

To use Together AI TTS services, install the required dependencies:

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

## Prerequisites

### Together AI Account Setup

Before using Together AI TTS services, you need:

1. **Together AI Account**: Sign up at [Together AI](https://together.ai/)
2. **API Key**: Generate an API key from your account dashboard
3. **Model Selection**: Choose from available TTS models and voices

### Required Environment Variables

* `TOGETHER_API_KEY`: Your Together AI API key for authentication

## Configuration

**api\_key** `str` *required*

Together AI API key for authentication.

**url** `str` (default: wss\://api.together.ai/v1/audio/speech/websocket)

WebSocket URL for Together AI TTS API.

**sample\_rate** `int | None` (default: 24000)

Output sample rate for emitted PCM frames. Together AI streams at 24 kHz and
does not support other rates, so leave this at 24000: any other value only
logs a warning, and the audio plays at the wrong speed and pitch.

**settings** `TogetherTTSService.Settings` (default: None)

Runtime-configurable settings. See [Settings](#settings) below.

### Settings

Runtime-configurable settings passed via the `settings` constructor argument using `TogetherTTSService.Settings(...)`. These can be updated mid-conversation with `TTSUpdateSettingsFrame`. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"hexgrad/Kokoro-82M"` | Model identifier. *(Inherited.)* |
| `voice` | `str` | `"af_heart"` | Voice identifier. *(Inherited.)* |
| `language` | `Language \| str` | `Language.EN` | Language for synthesis. *(Inherited.)* |
| `max_partial_length` | `int \| None` | `None` | Maximum partial text length for streaming. `None` leaves it unset, so Together AI's default applies. |
| `extra_params` | `dict \| None` | `None` | Model-specific synthesis options sent in the session update, such as `pronunciation_dict`, a list of `"<source>/<replacement>"` entries. If this doesn't give the results you want, try `replace_text` rules through the `text_transforms` parameter, which Pipecat applies before the text reaches the provider. |

## Usage

### Basic Setup

```python theme={null}
import os
from pipecat.services.together.tts import TogetherTTSService

tts = TogetherTTSService(
    api_key=os.getenv("TOGETHER_API_KEY"),
)
```

### With Custom Settings

```python theme={null}
from pipecat.services.together.tts import TogetherTTSService
from pipecat.transcriptions.language import Language

tts = TogetherTTSService(
    api_key=os.getenv("TOGETHER_API_KEY"),
    settings=TogetherTTSService.Settings(
        model="hexgrad/Kokoro-82M",
        voice="af_heart",
        language=Language.EN,
    ),
)
```

### In a Voice Pipeline

```python theme={null}
from pipecat.pipeline.pipeline import Pipeline
from pipecat.services.together.tts import TogetherTTSService

tts = TogetherTTSService(
    api_key=os.getenv("TOGETHER_API_KEY"),
    settings=TogetherTTSService.Settings(
        voice="af_heart",
        model="hexgrad/Kokoro-82M",
    ),
)

pipeline = Pipeline([
    # ... upstream processors
    llm,
    tts,
    transport.output(),
])
```

## Notes

* Together AI TTS streams audio at 24 kHz. The service outputs 24 kHz signed 16-bit mono PCM; the transport layer resamples to the pipeline's configured rate if needed.
* The service supports interruption handling and automatically clears the text buffer when interrupted.
* Audio is streamed incrementally via WebSocket deltas for low-latency synthesis.


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