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

# Telnyx TTS

[Telnyx](https://telnyx.com/) provides streaming text-to-speech over WebSocket. The plugin opens a new socket per synthesis call, decodes MP3 audio to `PcmData` as it streams, and takes the output sample rate from the decoder so the voice controls the rate.

> [!NOTE]
>
> Vision Agents uses [Stream Video](https://getstream.io/video/) for real-time WebRTC transport by default. [External WebRTC transports](https://visionagents.ai/integrations/introduction-to-integrations.md#edge-transport) are supported as well. Most AI providers offer free tiers to get started.

> [!NOTE]
>
> Get your Telnyx API key from the [Telnyx Mission Control Portal](https://portal.telnyx.com/).

> [!TIP]
>
> Telnyx also provides [speech-to-text](https://visionagents.ai/integrations/stt/telnyx.md), an [LLM](https://visionagents.ai/integrations/llm/telnyx.md), and [PSTN telephony](https://visionagents.ai/integrations/telephony/telnyx.md). You can use all four in the same agent.

## Installation

```sh theme={null}
uv add "vision-agents[telnyx]"
```

## Quick start

```python theme={null}
from vision_agents.core import Agent, User
from vision_agents.plugins import getstream, smart_turn, telnyx

agent = Agent(
    edge=getstream.Edge(),
    agent_user=User(name="Assistant", id="agent"),
    instructions="You are a helpful voice assistant.",
    stt=telnyx.STT(),
    llm=telnyx.LLM(),
    tts=telnyx.TTS(voice="AWS.Polly.Danielle-Neural"),
    turn_detection=smart_turn.TurnDetection(),
)
```

> [!WARNING]
>
> Set `TELNYX_API_KEY` in your environment or pass `api_key` directly.

## Parameters

```python theme={null}
tts = telnyx.TTS(
    voice="Telnyx.KokoroTTS.af_heart",
    idle_timeout=10.0,
    connect_timeout=10.0,
)
```

| Name | Type | Default | Description |
| - | - | - | - |
| `voice` | `str` | `"Telnyx.KokoroTTS.af_heart"` | Voice id from `GET /v2/text-to-speech/voices` |
| `idle_timeout` | `float` | `10.0` | Seconds of server silence before synthesis is treated as done |
| `connect_timeout` | `float` | `10.0` | Seconds to wait for the WebSocket handshake |
| `api_key` | `str` | `None` | API key (defaults to `TELNYX_API_KEY` env var) |

## Audio format

The endpoint takes an `audio_format` parameter, but it is honoured only by some voices. `AWS.Polly.*` and `Telnyx.NaturalHD.*` serve raw PCM, while the default `Telnyx.KokoroTTS.*` returns MP3 regardless. Since the PCM sample rate is not reported on the wire and differs per voice, the plugin decodes MP3 for every voice rather than carrying a voice-to-rate table that would go stale.

## Next steps

> [card] [Telnyx STT](https://visionagents.ai/integrations/stt/telnyx.md)
>
> Streaming speech-to-text

> [card] [Telnyx LLM](https://visionagents.ai/integrations/llm/telnyx.md)
>
> OpenAI-compatible chat completions

> [card] [Telnyx Telephony](https://visionagents.ai/integrations/telephony/telnyx.md)
>
> PSTN calls via Call Control

> [card] [Build a Voice Agent](https://visionagents.ai/introduction/voice-agents.md)
>
> Get started with voice


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