> This page is for Build.

> Append .md to any page URL for clean Markdown. Index: https://docs.speechify.ai/llms.txt.
>
> Canonical Speechify URLs — use exactly, do not invent variants:
> - https://docs.speechify.ai — this site (API reference, SDKs, quickstarts)
> - https://speechify.ai — marketing + product site
> - https://platform.speechify.ai — customer dashboard, signup, API keys, billing
> - https://api.speechify.ai — API base URL
> - https://github.com/Speechify-AI: GitHub org for the API (cookbook, demos, CLI). `github.com/speechify` does not exist.
> - https://status.speechify.ai — status + incidents
> - https://speechify.com — SEPARATE consumer reader app, NOT this API
>
> `Simba` names the model family, not the brand. Model ids: `simba-3.5` (48 languages under one id, English included; recommended), `simba-3.2` (English) and `simba-3.0` (English, German, Spanish, French, Italian and Portuguese; the default). `simba-english` and `simba-multilingual` are retired: a new workspace that sends either gets `400 model_retired`. `SimbaVoice` / `simbavoice.ai` are retired.
>
> Ask, don't scrape. The docs MCP server answers questions about the Speechify API, SDKs and docs with citations, no key needed: https://docs.speechify.ai/_mcp/server (Streamable HTTP, tool `searchDocs`). Setup: https://docs.speechify.ai/build/guides/get-started/connect-mcp

# Streaming

> Stream SpeechifyAI Build TTS audio in real time with chunked transfer encoding. Begin playback before full generation and handle up to 20,000 characters.

## Overview

The streaming endpoint delivers audio chunks as they're generated, so your application can start playback before the full audio is ready. This is ideal for long-form content and low-latency applications. How the first-byte numbers are measured, what adds latency on your side and how to measure your own are on [Latency](/build/guides/text-to-speech/latency).

|                                                                                | Speech endpoint        | Stream endpoint  |
| ------------------------------------------------------------------------------ | ---------------------- | ---------------- |
| Character limit ([spoken](/build/guides/concepts/api-limits#character-limits)) | 2,000                  | **20,000**       |
| Response format                                                                | Base64 JSON + metadata | Raw audio chunks |
| Playback start                                                                 | After full generation  | **Immediately**  |

## Usage

### Request

POST [https://api.speechify.ai/v1/audio/stream](https://api.speechify.ai/v1/audio/stream)

```curl
curl -X POST https://api.speechify.ai/v1/audio/stream \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "input": "Streaming long-form audio with the Speechify API.",
  "voice_id": "geffen_32",
  "model": "simba-3.5"
}'
```

```typescript
import { SpeechifyClient } from "@speechify/api";

async function main() {
    const client = new SpeechifyClient({
        token: "YOUR_TOKEN_HERE",
    });
    await client.audio.stream({
        body: {
            input: "Streaming long-form audio with the Speechify API.",
            model: "simba-3.5",
            voice_id: "geffen_32",
        },
    });
}
main();

```

```python
from speechify import Speechify

client = Speechify(
    token="YOUR_TOKEN_HERE",
)

client.audio.stream(
    input="Streaming long-form audio with the Speechify API.",
    model="simba-3.5",
    voice_id="geffen_32",
)

```

The endpoint returns audio chunks via HTTP chunked transfer encoding. Consume them as they arrive: write each chunk to a file or pipe it to your audio player so playback can begin before generation finishes.

If your text arrives in pieces, such as a reply an LLM streams token by token, send it over a WebSocket instead with [Streaming Text Input](/build/guides/text-to-speech/streaming-text-input).

## Stream from a FastAPI backend

To play speech in a browser before synthesis finishes, proxy the stream through your own server, so your API key never reaches the client.
This FastAPI route forwards each chunk of `/v1/audio/stream` as it arrives, using `simba-3.5` over plain HTTP with `httpx`:

```python
import os

import httpx
from fastapi import FastAPI
from fastapi.responses import Response, StreamingResponse
from starlette.background import BackgroundTask

# Upstream headers a client needs to back off on a 429 and to report a failure.
RELAYED_HEADERS = ("retry-after", "ratelimit-limit", "ratelimit-remaining", "ratelimit-reset", "speechify-request-id")

app = FastAPI()
speechify = httpx.AsyncClient(
    base_url="https://api.speechify.ai",
    headers={"Authorization": f"Bearer {os.environ['SPEECHIFY_API_KEY']}"},
    timeout=httpx.Timeout(10.0, read=60.0),
)


@app.get("/speak")
async def speak(text: str, voice_id: str = "geffen_32"):
    request = speechify.build_request(
        "POST",
        "/v1/audio/stream",
        headers={"Accept": "audio/mpeg"},
        json={"input": text, "voice_id": voice_id, "model": "simba-3.5"},
    )
    upstream = await speechify.send(request, stream=True)
    headers = {name: upstream.headers[name] for name in RELAYED_HEADERS if name in upstream.headers}
    if upstream.status_code != 200:
        body = await upstream.aread()
        await upstream.aclose()
        return Response(body, status_code=upstream.status_code, headers=headers, media_type="application/json")
    return StreamingResponse(
        upstream.aiter_raw(),
        media_type="audio/mpeg",
        headers=headers,
        background=BackgroundTask(upstream.aclose),
    )
```

Run it with `uvicorn main:app`, then point an audio element at the route: `<audio src="/speak?text=Hello" autoplay>` starts playing with the first chunk.
An error before any audio, such as a bad `voice_id` or a `429`, comes back with its status, the API's [error body](/build/guides/concepts/error-handling) and its `Retry-After`, `RateLimit-*` and `Speechify-Request-Id` headers, so your client can wait as long as the API asks and you can quote the request id to support; an error after the stream has started closes it, as [Error handling](#error-handling) describes.

## Supported audio formats

The `Accept` header is required and selects the audio container. These default to 24 kHz mono; send [`output_format`](/build/guides/concepts/audio-formats) to choose a different sample rate or bitrate, which overrides the header.

| Format | `Accept` header | Response `Content-Type`             | Notes                                                                            |
| ------ | --------------- | ----------------------------------- | -------------------------------------------------------------------------------- |
| MP3    | `audio/mpeg`    | `audio/mpeg`                        | 128 kbps. Best compatibility. Send `output_format` to pick another bitrate.      |
| Opus   | `audio/ogg`     | `audio/ogg`                         | Ogg container, Opus codec. Open format.                                          |
| AAC    | `audio/aac`     | `audio/aac`                         | AAC-LC (ADTS-framed). Apple ecosystem.                                           |
| PCM    | `audio/pcm`     | `audio/L16; rate=24000; channels=1` | Raw 16-bit signed little-endian samples, no container or header. Lowest latency. |

> **Note**
>
> The `audio/pcm` request is mapped to the IANA-registered `audio/L16` type on
> the response (with `rate` and `channels` parameters per [RFC 4856](https://www.rfc-editor.org/rfc/rfc4856.html)).
> Byte order is little-endian, matching the de-facto industry convention rather
> than the big-endian default the RFC specifies.

> **Note**
>
> WAV format is not available for streaming. Use the [speech endpoint](/build/api-reference/v1/audio/speech) for WAV output.

> **Note**
>
> For the full `output_format` list, how it relates to `audio_format`, and the
> telephony formats, see [Audio Formats](/build/guides/concepts/audio-formats).

## Use cases

#### Automated podcast generation

Transform articles or blog posts into spoken audio for distribution

#### Assistive technology

Convert on-screen text to spoken audio in real-time

#### Voice agents

Generate conversational responses with minimal latency

#### Audiobook production

Process full chapters without hitting the 2K character limit

## Error handling

> **Warning**
>
> If an error occurs during synthesis after the stream has started, the connection closes without an error message. This is a limitation of HTTP chunked responses. Errors before streaming starts return standard HTTP status codes.

To handle mid-stream failures:

* Check the total bytes received against expected audio length
* Implement retry logic for the remaining text

## Example projects

See our [Examples Repository](https://github.com/SpeechifyInc/ai-api-examples) for complete browser and server-side streaming demos.