Skip to main content
Gemini Text-to-Speech
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.
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.