> ## Documentation Index
> Fetch the complete documentation index at: https://daily-docs-source-analytics-user-turn-strategies.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Together AI

> Text-to-speech service using Together AI's real-time WebSocket API

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

<CardGroup cols={2}>
  <Card title="Together AI TTS API Reference" icon="code" href="https://reference-server.pipecat.ai/en/latest/api/pipecat.services.together.tts.html">
    Pipecat's API methods for Together AI TTS
  </Card>

  <Card title="Example Implementation" icon="play" href="https://github.com/pipecat-ai/pipecat/blob/main/examples/voice/voice-together.py">
    Complete voice bot example
  </Card>

  <Card title="Together AI Documentation" icon="book" href="https://docs.together.ai/reference/audio-speech-websocket">
    Official Together AI TTS WebSocket API documentation
  </Card>

  <Card title="Together AI Platform" icon="microphone" href="https://together.ai/">
    Access models and manage API keys
  </Card>
</CardGroup>

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

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

<ParamField path="url" type="str" default="wss://api.together.ai/v1/audio/speech/websocket">
  WebSocket URL for Together AI TTS API.
</ParamField>

<ParamField path="sample_rate" type="int" default="24000">
  Output sample rate for emitted PCM frames. Together AI streams at 24 kHz and
  does not support other rates.
</ParamField>

<ParamField path="settings" type="TogetherTTSService.Settings" default="None">
  Runtime-configurable settings. See [Settings](#settings) below.
</ParamField>

### Settings

Runtime-configurable settings passed via the `settings` constructor argument using `TogetherTTSService.Settings(...)`. These can be updated mid-conversation with `TTSUpdateSettingsFrame`. See [Service Settings](/pipecat/fundamentals/service-settings) 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` for no cap. |

## Usage

### Basic Setup

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

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

### With Custom Settings

```python theme={null}
from pipecat.services.together 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 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.
