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

# Gemini Text-to-Speech

> Use `contents[].parts[].text` for the words to speak and set `generationConfig.responseModalities` to `["AUDIO"]`. Configure the prebuilt voice under `generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceName`.

Use a MixRoute API key and the exact model ID in the request path. This guide describes MixRoute's GenerateContent request format.

`POST /v1/models/{model}:generateContent`

Some model guides also list `POST /v1beta/models/{model}:generateContent`. Use the version specified for your model; the examples below use `/v1`.

## Model ID

* `gemini-2.5-flash-preview-tts`
* `gemini-2.5-pro-preview-tts`
* `gemini-3.1-flash-tts-preview`
* `gemini-3.8-flash-lite-tts`
* `gemini-3.8-flash-tts`

## Request and response

Use `contents[].parts[].text` for the words to speak and set `generationConfig.responseModalities` to `["AUDIO"]`. Configure the prebuilt voice under `generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceName`.

Use `speechMetadata.style` for delivery instructions on routes that document it, such as Gemini 3.8 TTS. Voice sets, single or multiple speakers, and output encoding vary by model.

```bash theme={null}
curl --request POST 'https://api.mixroute.ai/v1/models/gemini-3.8-flash-tts:generateContent' \
  --header "Authorization: Bearer $MIXROUTE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "contents": [
    {
      "parts": [
        {
          "text": "Welcome to MixRoute."
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": [
      "AUDIO"
    ],
    "speechConfig": {
      "voiceConfig": {
        "prebuiltVoiceConfig": {
          "voiceName": "Kore"
        }
      }
    }
  }
}'
```

On success, read `candidates[].content.parts[].inlineData`. Decode `data` from Base64 and use `mimeType` to determine whether it is WAV or another encoding. Do not add a WAV header to bytes already encoded as WAV.

Availability and supported fields depend on your MixRoute route. Check the model page before assuming that streaming or a different request format is available.


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