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

# TTS

> Text-to-speech endpoints

## Overview

Text-to-speech endpoints

### Available Operations

* [create\_speech](#create_speech) - Create speech
* [list\_models](#list_models) - List text-to-speech models
* [get\_model](#get_model) - Get a text-to-speech model

## create\_speech

Synthesizes audio from the input text. Returns a raw audio bytestream in the requested format (e.g. mp3, pcm) by default, or a JSON response with a 24-hour signed download URL when `output_delivery` is set to `"url"`.

### Example Usage

```python theme={null}
from openrouter import OpenRouter
import os


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
    api_key=os.getenv("OPENROUTER_API_KEY", ""),
) as open_router:

    res = open_router.tts.create_speech(input="Hello world", model="mistralai/voxtral-mini-tts-2603", response_format="pcm", speed=1.0, voice="en_paul_neutral")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `input` | [components.SpeechInput](../../components/speechinput.mdx) | ✔️ | Text to synthesize, or a list of turns for multi-speaker input. Each turn has its own text, voice, and instructions. Multi-speaker input is supported by Gemini TTS models, by Fish Audio models other than S1, and by Speechify dialogue models. | Hello world |
| `model` | *str* | ✔️ | TTS model identifier | mistralai/voxtral-mini-tts-2603 |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `input_references` | List\[[components.SpeechInputReference](../../components/speechinputreference.mdx)] | ➖ | Reference content for stateless voice cloning or voice design. Audio mode: one to three `input_audio` parts, each optionally paired with a `text` part carrying its transcript (a single clip accepts its transcript before or after it; with multiple clips each transcript immediately follows its clip), plus at most one `image_url` part as a scene image on providers that condition the cloned voice on its setting; only routed to endpoints that support voice cloning (and multiple references or image references when those parts are sent). Image mode: exactly one `image_url` part; only routed to endpoints that support image references. Video mode: exactly one `video_url` part with a public http(s) URL, optionally with one to three `input_audio` parts (and their `text` transcripts) grouped as in audio mode, and no `image_url` part; Seed Audio 1.5 ignores those transcripts, so the words the voices speak go in `input`; only routed to endpoints that support video references (and voice cloning when clips are sent, plus multiple references for two or three clips). An empty array is treated as no reference. | \[ \{ "input\_audio": \{ "data": "data:audio/wav;base64,UklGRuQXDABXQVZF..." }, "type": "input\_audio" }, \{ "text": "I used to rule the world.", "type": "text" } ] |
| `instructions` | *Optional\[str]* | ➖ | Delivery instructions for the whole request, such as tone, pacing, or emotion. For the selected endpoint in the [Speech Models API](https://openrouter.ai/docs/guides/overview/multimodal/tts.md#via-the-speech-models-api), look for `supported_parameters.instructions` in the `output_modalities` entry with `type: speech`. | Speak in a warm and friendly tone. |
| `output_delivery` | [Optional\[components.OutputDelivery\]](../../components/outputdelivery.mdx) | ➖ | `stream` (default) streams the audio bytes directly in the response body (returns inline base64 JSON when `timestamp_granularities` is nonempty and `stream_format` is `"audio"`, or `text/event-stream` events when `stream_format` is `"sse"`). `url` stores the generated audio in OpenRouter storage and returns a JSON response with a signed download `url`, `expires_at`, and `media_type` (plus `words` and/or `characters` when `timestamp_granularities` is nonempty). The URL is a bearer link: anyone holding it can download the audio until it expires, up to 24 hours after the audio was stored (use `expires_at`); the stored copy is deleted by the storage lifecycle within the following day. When a URL cannot be issued (zero-data-retention via account settings, guardrails, `provider.zdr`, or a ZDR endpoint; no workspace; or storage failure), untimed requests fall back to streaming raw audio bytes (except on a storage failure for responses larger than 10 MiB, which returns an error), and timed requests fall back to inline base64 JSON (`{audio, media_type, words?, characters?}`) with no `url`. | stream |
| `provider` | [Optional\[components.SpeechRequestProvider\]](../../components/speechrequestprovider.mdx) | ➖ | Provider configuration: provider routing preferences (`order`, `only`, `ignore`, `allow_fallbacks`), data policy routing preferences (`zdr`, `data_collection`) and provider-specific passthrough options | |
| `response_format` | [Optional\[components.SpeechRequestResponseFormat\]](../../components/speechrequestresponseformat.mdx) | ➖ | Audio output format. Defaults to `pcm`, or to `mp3` when `timestamp_granularities` is nonempty. | pcm |
| `separate_tracks` | *Optional\[bool]* | ➖ | Split one existing audio clip into separate tracks (speech, sound effects, background music) instead of generating speech. Requires exactly one `input_audio` part in `input_references` and no other parts, `voice` or `timestamp_granularities`, and `speed` omitted or `1`; `input` describes how to split the clip (for example "all speech in one track, background music in one track, all sound effects in one track"). The response is always JSON (`SpeechSeparatedTracksResponse`): `{tracks: [{type, description, audio, media_type}]}` with base64 audio, or `url` and `expires_at` per track when `output_delivery` is `url`. The audio defaults to `mp3` unless `response_format` is set. The whole output is buffered and capped at 10 MiB of decoded audio across all tracks inline, or 32 MiB with `url` delivery. With `output_delivery: "url"`, tracks fall back to inline base64 `audio` (no `url`) under the 10 MiB inline cap when a signed URL cannot be issued (zero-data-retention, missing workspace, or storage failure), so the 32 MiB cap only applies when storage is available. Only routed to endpoints that price track separation (`supported_parameters.separate_tracks` on the speech models list). Generated SDKs type the 200 response as binary audio; call the HTTP endpoint directly and parse the JSON. | true |
| `session_id` | *Optional\[str]* | ➖ | A unique identifier for grouping related requests (e.g., a conversation or agent workflow). Used for observability grouping in Broadcast and private logging; never sent to the provider. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters. | session-1234 |
| `speed` | *Optional\[float]* | ➖ | Playback speed multiplier. Honored by models that support it (e.g. OpenAI TTS). Other providers either ignore it or return a 400 for a non-default value when the model has no speed control. | 1 |
| `stream_format` | [Optional\[components.StreamFormat\]](../../components/streamformat.mdx) | ➖ | Wire framing for inline responses. `audio` (default) returns raw audio bytes (or a buffered JSON envelope when `timestamp_granularities` is nonempty). `sse` streams `text/event-stream` events (`speech.audio.delta`, `speech.timestamps.delta` when `timestamp_granularities` is nonempty, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type`. Cannot be combined with `output_delivery: "url"`. Only routed to endpoints that advertise `sse` in `supported_parameters.stream_format` (and every requested granularity when `timestamp_granularities` is nonempty). Generated SDKs still type the 200 response as binary audio for compatibility; when using `stream_format: "sse"`, call the HTTP endpoint directly and parse `text/event-stream`. | audio |
| `timestamp_granularities` | List\[[components.TimestampGranularity](../../components/timestampgranularity.mdx)] | ➖ | Timings to return with the audio. With the default `stream_format: "audio"`, the response is buffered JSON instead of raw audio bytes: `{audio, media_type, words?, characters?}` with base64 audio, or `{url, expires_at, media_type, words?, characters?}` when `output_delivery` is `url`. If a signed URL cannot be issued (ZDR, no workspace, or storage failure), timed `url` requests fall back to the inline `{audio, media_type, ...}` envelope with no `url`. Buffered timed responses are sent once the whole audio is generated and are capped at 10 MiB of decoded audio (the provider timed response, including its alignment data, is capped too); longer outputs return an error, so use a shorter input, a smaller audio format, or `stream_format: "sse"`. With `stream_format: "sse"`, the response is `text/event-stream` (`speech.audio.delta`, `speech.timestamps.delta`, `speech.audio.done`, and `error` on mid-stream failure) with the effective audio media type in `X-Audio-Media-Type` and no 10 MiB cap. The audio defaults to `mp3` unless `response_format` is set. Each timing entry is `{text, start, end}` in seconds. Only routed to endpoints that support every requested granularity for the requested `stream_format`. Generated SDKs still type the 200 response as binary audio for compatibility; call the HTTP endpoint directly and parse JSON (for `stream_format: "audio"`) or `text/event-stream` (for `stream_format: "sse"`). An empty array is treated as no timings. | \[ "word" ] |
| `trace` | [Optional\[components.TraceConfig\]](../../components/traceconfig.mdx) | ➖ | Metadata for observability and tracing. Known keys (trace\_id, trace\_name, span\_name, generation\_name, parent\_span\_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations. | \{ "trace\_id": "trace-abc123", "trace\_name": "my-app-trace" } |
| `user` | *Optional\[str]* | ➖ | A unique identifier representing your end-user. Forwarded to Broadcast and private logging as the end-user id; never sent to the provider. | user-1234 |
| `voice` | *Optional\[str]* | ➖ | Voice identifier (provider-specific). Required by most providers; only Seed Audio, HeyGen, Fish Audio, AssemblyAI, Speechify accept requests without it. | en\_paul\_neutral |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[httpx.Response](../../models/.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.BadRequestResponseError | 400 | application/json |
| errors.UnauthorizedResponseError | 401 | application/json |
| errors.PaymentRequiredResponseError | 402 | application/json |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.PayloadTooLargeResponseError | 413 | application/json |
| errors.TooManyRequestsResponseError | 429 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.BadGatewayResponseError | 502 | application/json |
| errors.ServiceUnavailableResponseError | 503 | application/json |
| errors.GatewayTimeoutResponseError | 504 | application/json |
| errors.EdgeNetworkTimeoutResponseError | 524 | application/json |
| errors.ProviderOverloadedResponseError | 529 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## list\_models

Lists every text-to-speech model with the inputs it accepts and its speech output parameters, merged across its endpoints, plus each endpoint with its own.

### Example Usage

```python theme={null}
from openrouter import OpenRouter


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
) as open_router:

    res = open_router.tts.list_models()

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. |

### Response

**[components.SpeechModelsListResponse](../../components/speechmodelslistresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ServiceUnavailableResponseError | 503 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |

## get\_model

Returns a text-to-speech model with each endpoint's own inputs and speech output parameters.

### Example Usage

```python theme={null}
from openrouter import OpenRouter


with OpenRouter(
    http_referer="<value>",
    x_open_router_title="<value>",
    x_open_router_categories="<value>",
) as open_router:

    res = open_router.tts.get_model(author="openai", slug="gpt-4o-mini-tts")

    # Handle response
    print(res)

```

### Parameters

| Parameter | Type | Required | Description | Example |
| - | - | - | - | - |
| `author` | *str* | ✔️ | Model author/organization | openai |
| `slug` | *str* | ✔️ | Model slug | gpt-4o-mini-tts |
| `http_referer` | *Optional\[str]* | ➖ | The app identifier should be your app's URL and is used as the primary identifier for rankings. This is used to track API usage per application.  | |
| `x_open_router_title` | *Optional\[str]* | ➖ | The app display name allows you to customize how your app appears in OpenRouter's dashboard.  | |
| `x_open_router_categories` | *Optional\[str]* | ➖ | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.  | |
| `retries` | [Optional\[utils.RetryConfig\]](../../models/utils/retryconfig.mdx) | ➖ | Configuration to override the default retry behavior of the client. | |

### Response

**[components.SpeechModelResponse](../../components/speechmodelresponse.mdx)**

### Errors

| Error Type | Status Code | Content Type |
| - | - | - |
| errors.ForbiddenResponseError | 403 | application/json |
| errors.NotFoundResponseError | 404 | application/json |
| errors.InternalServerResponseError | 500 | application/json |
| errors.ServiceUnavailableResponseError | 503 | application/json |
| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* |
