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

# Gemini 2.5 Flash TTS Text-to-Speech

Converts text to speech based on the Vertex AI generateContent API. The request body format is fully consistent with the official Vertex AI API. Supports both synchronous (single request, single response) and streaming (single request, streamed response) modes. Output is in LINEAR16 PCM format (24kHz, mono, 16-bit signed little-endian) without a WAV header.

## Request Headers

<ParamField header="Content-Type" type="string" required={true}>
  Enum: `application/json`
</ParamField>

<ParamField header="Authorization" type="string" required={true}>
  Bearer authentication format: Bearer \{\{API Key}}.
</ParamField>

## Request Body

<ParamField body="contents" type="object" required={true}>
  <Expandable title="properties" defaultOpen={true}>
    <ParamField body="role" type="string" required={true} default="user">
      Role, fixed as user

      Possible values: `user`
    </ParamField>

    <ParamField body="parts" type="object" required={true}>
      <Expandable title="properties" defaultOpen={true}>
        <ParamField body="text" type="string" required={true}>
          The text content to synthesize into speech. The Vertex AI API combines prompt and text in a single field, formatted as '{prompt}: {text}', e.g., 'Say the following in a curious way: OK, so... tell me about this AI thing.'. Maximum size is 8000 bytes; audio exceeding 655 seconds will be truncated. Supports inline markup tags: \[sigh], \[laughing], \[uhm], \[sarcasm], \[robotic], \[shouting], \[whispering], \[extremely fast], \[short pause], \[medium pause], \[long pause]

          Length limit: 0 - 8000
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="generation_config" type="object" required={true}>
  <Expandable title="properties" defaultOpen={true}>
    <ParamField body="temperature" type="number" default={2}>
      Temperature parameter that controls randomness and creativity in speech generation. Higher values produce more creative and diverse output; lower values produce more predictable and focused output. Valid range is (0.0, 2.0], recommended value is 2.0

      Range: \[0, 2]
    </ParamField>

    <ParamField body="speech_config" type="object" required={true}>
      <Expandable title="properties" defaultOpen={true}>
        <ParamField body="voice_config" type="object">
          Single-speaker voice configuration. Mutually exclusive with multi\_speaker\_voice\_config

          <Expandable title="properties" defaultOpen={true}>
            <ParamField body="prebuilt_voice_config" type="object">
              <Expandable title="properties" defaultOpen={true}>
                <ParamField body="voice_name" type="string">
                  Prebuilt voice name (case-insensitive). 30 available voices (both male and female)

                  Possible values: `Achernar`, `Achird`, `Algenib`, `Algieba`, `Alnilam`, `Aoede`, `Autonoe`, `Callirrhoe`, `Charon`, `Despina`, `Enceladus`, `Erinome`, `Fenrir`, `Gacrux`, `Iapetus`, `Kore`, `Laomedeia`, `Leda`, `Orus`, `Pulcherrima`, `Puck`, `Rasalgethi`, `Sadachbia`, `Sadaltager`, `Schedar`, `Sulafat`, `Umbriel`, `Vindemiatrix`, `Zephyr`, `Zubenelgenubi`
                </ParamField>
              </Expandable>
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="language_code" type="string" required={true}>
          Language code (BCP-47 format, case-insensitive). GA languages: ar-EG, bn-BD, nl-NL, en-IN, en-US, fr-FR, de-DE, hi-IN, id-ID, it-IT, ja-JP, ko-KR, mr-IN, pl-PL, pt-BR, ro-RO, ru-RU, es-ES, ta-IN, te-IN, th-TH, tr-TR, uk-UA, vi-VN. Preview languages include cmn-CN (Mandarin Chinese) and 63 others

          Possible values: `af-ZA`, `am-ET`, `ar-001`, `ar-EG`, `az-AZ`, `be-BY`, `bg-BG`, `bn-BD`, `ca-ES`, `ceb-PH`, `cmn-CN`, `cmn-TW`, `cs-CZ`, `da-DK`, `de-DE`, `el-GR`, `en-AU`, `en-GB`, `en-IN`, `en-US`, `es-419`, `es-ES`, `es-MX`, `et-EE`, `eu-ES`, `fa-IR`, `fi-FI`, `fil-PH`, `fr-CA`, `fr-FR`, `gl-ES`, `gu-IN`, `he-IL`, `hi-IN`, `hr-HR`, `ht-HT`, `hu-HU`, `hy-AM`, `id-ID`, `is-IS`, `it-IT`, `ja-JP`, `jv-JV`, `ka-GE`, `kn-IN`, `ko-KR`, `kok-IN`, `la-VA`, `lb-LU`, `lo-LA`, `lt-LT`, `lv-LV`, `mai-IN`, `mg-MG`, `mk-MK`, `ml-IN`, `mn-MN`, `mr-IN`, `ms-MY`, `my-MM`, `nb-NO`, `ne-NP`, `nl-NL`, `nn-NO`, `or-IN`, `pa-IN`, `pl-PL`, `ps-AF`, `pt-BR`, `pt-PT`, `ro-RO`, `ru-RU`, `sd-IN`, `si-LK`, `sk-SK`, `sl-SI`, `sq-AL`, `sr-RS`, `sv-SE`, `sw-KE`, `ta-IN`, `te-IN`, `th-TH`, `tr-TR`, `uk-UA`, `ur-PK`, `vi-VN`
        </ParamField>

        <ParamField body="multi_speaker_voice_config" type="object">
          Multi-speaker voice configuration. Mutually exclusive with voice\_config. Note: gemini-2.5-flash-lite-preview-tts does not support multi-speaker synthesis

          <Expandable title="properties" defaultOpen={true}>
            <ParamField body="speaker_voice_configs" type="array">
              List of speaker voice configurations

              <Expandable title="properties" defaultOpen={true}>
                <ParamField body="speaker" type="string" required={true}>
                  Speaker alias, must consist of alphanumeric characters only, no spaces. Must match the speaker identifier in contents.parts.text
                </ParamField>

                <ParamField body="voice_config" type="object" required={true}>
                  <Expandable title="properties" defaultOpen={true}>
                    <ParamField body="prebuilt_voice_config" type="object">
                      <Expandable title="properties" defaultOpen={true}>
                        <ParamField body="voice_name" type="string">
                          Prebuilt voice name (case-insensitive). 30 available voices (both male and female)

                          Possible values: `Achernar`, `Achird`, `Algenib`, `Algieba`, `Alnilam`, `Aoede`, `Autonoe`, `Callirrhoe`, `Charon`, `Despina`, `Enceladus`, `Erinome`, `Fenrir`, `Gacrux`, `Iapetus`, `Kore`, `Laomedeia`, `Leda`, `Orus`, `Pulcherrima`, `Puck`, `Rasalgethi`, `Sadachbia`, `Sadaltager`, `Schedar`, `Sulafat`, `Umbriel`, `Vindemiatrix`, `Zephyr`, `Zubenelgenubi`
                        </ParamField>
                      </Expandable>
                    </ParamField>
                  </Expandable>
                </ParamField>
              </Expandable>
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="audioContent" type="string" required={false}>
  Base64 encoded audio content. Format is LINEAR16 PCM (24kHz, mono, 16-bit signed little-endian) without a WAV header. Clients can convert using ffmpeg: ffmpeg -f s16le -ar 24k -ac 1 -i input.raw output.wav
</ResponseField>

<ResponseField name="usageMetadata" type="object" required={false}>
  <Expandable title="properties" defaultOpen={true}>
    <ResponseField name="totalTokenCount" type="integer" required={false}>
      Total token count (promptTokenCount + candidatesTokenCount)
    </ResponseField>

    <ResponseField name="promptTokenCount" type="integer" required={false}>
      Number of tokens consumed by the input text
    </ResponseField>

    <ResponseField name="candidatesTokenCount" type="integer" required={false}>
      Number of tokens consumed by the output audio (approximately 25 tokens per second of audio)
    </ResponseField>
  </Expandable>
</ResponseField>
