> ## Documentation Index
> Fetch the complete documentation index at: https://veniceai-tombystrican-api-103-update-and-re-enable-public-s.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Text-to-Speech

> Generate spoken audio from text with Venice text-to-speech models, choose a model-specific voice, and save the binary response from the /audio/speech endpoint.

Text-to-speech turns written text into spoken audio. Choose a TTS model, select a voice supported by that model, send text to `/audio/speech`, and save the binary audio response.

Use this guide for standard voice generation. If you want to create speech from a custom reference voice, see [Voice Cloning](/guides/media/voice-cloning).

## Basic Usage

<CodeGroup>
  ```python Python theme={null}
  import os
  from pathlib import Path

  import requests

  response = requests.post(
      "https://api.venice.ai/api/v1/audio/speech",
      headers={
          "Authorization": f"Bearer {os.environ['VENICE_API_KEY']}",
          "Content-Type": "application/json",
      },
      json={
          "model": "tts-kokoro",
          "voice": "af_sky",
          "input": "Hello, welcome to Venice Voice.",
      },
  )

  response.raise_for_status()
  Path("speech.mp3").write_bytes(response.content)
  ```

  ```javascript Node.js theme={null}
  import { writeFile } from "node:fs/promises";

  const response = await fetch("https://api.venice.ai/api/v1/audio/speech", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.VENICE_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "tts-kokoro",
      voice: "af_sky",
      input: "Hello, welcome to Venice Voice.",
    }),
  });

  if (!response.ok) {
    throw new Error(await response.text());
  }

  await writeFile("speech.mp3", Buffer.from(await response.arrayBuffer()));
  ```

  ```bash cURL theme={null}
  curl https://api.venice.ai/api/v1/audio/speech \
    -H "Authorization: Bearer $VENICE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "tts-kokoro",
      "voice": "af_sky",
      "input": "Hello, welcome to Venice Voice."
    }' \
    --output speech.mp3
  ```
</CodeGroup>

The successful response body is binary audio in the model's default format, not JSON. `tts-kokoro` currently defaults to MP3.

## Choose a Model and Voice

Voices are model-specific. The `voice` value must be valid for the `model` you choose.

Use the [Text-to-Speech Models](/models/text-to-speech) page to browse available models and voices. The voice picker lists the exact voice IDs to pass in your request.

<Note>
  Voice IDs are case-sensitive. If you switch TTS models, update the `voice` value at the same time.
</Note>

## Request Shape

| Parameter         | Type   | Required | Description                                                                                                                   |
| ----------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `model`           | string | Yes      | Text-to-speech model ID.                                                                                                      |
| `voice`           | string | Yes      | Voice ID supported by the selected model.                                                                                     |
| `input`           | string | Yes      | Text to synthesize, up to 4096 characters.                                                                                    |
| `response_format` | string | No       | Requested output format: `mp3`, `opus`, `aac`, `flac`, `wav`, or `pcm`. Supported formats and the default are model-specific. |

## Output Format

You can omit `response_format` to use the model's default. Before choosing a file extension or overriding the format, query the Models API for the model's current `default_format` and `supported_formats`:

```bash theme={null}
curl "https://api.venice.ai/api/v1/models?type=tts" \
  -H "Authorization: Bearer $VENICE_API_KEY" |
  jq '.data[] | select(.id == "tts-kokoro") | .model_spec | {default_format, supported_formats}'
```

The response `Content-Type` identifies the returned audio format. Requesting a format that the selected model does not support returns HTTP `400`.

## Production Tips

* Cache generated audio when the source text and voice are reused.
* Normalize and proofread text before synthesis. Punctuation affects pacing and intonation.
* Store output with the correct file extension for the model's response format.

## Related Resources

* [Audio Speech API](/api-reference/endpoint/audio/speech)
* [Text-to-Speech Models](/models/text-to-speech)
* [Voice Cloning Guide](/guides/media/voice-cloning)
