gemini-3.8-flash-tts over the native Gemini endpoint. Requests return audio synchronously—there is no task ID or polling.Model availability is determined by the live GET /v1/modelsresponse for your API key. Do not submit synthesis requests if the model does not appear in that list.
Authorization: Bearer, x-goog-api-key, or the ?key= query parameter. Only the native Gemini generateContent format is supported; OpenAI formats (/v1/chat/completions, /v1/audio/speech) are not available.This endpoint extends the native Gemini payload with a part-level speech_metadataobject for vocal style and speaker assignment. Official Google SDKs do not generatespeech_metadataautomatically, so include it manually in your JSON payload. Multi-speaker dialogue requiresspeech_metadata.speakeron every part—prefixing speaker names insidetext(such as"Alex: ...") cannot substitute for it.
| Field | Type | Required | Description |
|---|---|---|---|
contents | array | Yes | Must contain a single content item. |
contents[].role | string | No | Set to user. |
contents[].parts[].text | string | Yes | Text to speak aloud. Use one text part for single-speaker synthesis, or one part per line for multi-speaker dialogue. |
contents[].parts[].speech_metadata.style | string | No | Vocal delivery prompt, e.g. "tearful" or "low, restrained tone". Affects delivery only and is not spoken aloud. |
contents[].parts[].speech_metadata.speaker | string | Conditional | Required for multi-speaker dialogue. Speaker identifier for this line; must match a speaker entry in multiSpeakerVoiceConfig. |
generationConfig.responseModalities | string[] | Yes | Must be ["AUDIO"]. |
generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceName | string | Conditional | Required for single-speaker synthesis. Voice name from the list below; mutually exclusive with multiSpeakerVoiceConfig. |
generationConfig.speechConfig.multiSpeakerVoiceConfig.speakerVoiceConfigs | array | Conditional | Required for multi-speaker dialogue. One entry per speaker with speaker and voiceConfig.prebuiltVoiceConfig.voiceName; mutually exclusive with voiceConfig. |
Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, Sulafatspeech_metadata.speaker, and assign each speaker a voice in multiSpeakerVoiceConfig.{
"candidates": [{
"content": {
"role": "model",
"parts": [{
"inlineData": {
"mimeType": "audio/l16; rate=24000; channels=1",
"data": "BASE64_PCM_DATA"
}
}]
},
"finishReason": "STOP"
}],
"usageMetadata": {"promptTokenCount": 12, "candidatesTokenCount": 78, "totalTokenCount": 90},
"modelVersion": "gemini-3.8-flash-tts"
}inlineData.data is base64-encoded raw PCM (24000 Hz, mono, 16-bit signed little-endian) with no WAV header, so it cannot be played directly as .wav or .mp3. Convert it using either approach below:ffmpeg:multiSpeakerVoiceConfig is used, every text part must include speech_metadata.speaker; otherwise the API returns 400.speech_metadata.style, not inside text—cues placed inside text may be read aloud.X-Oneapi-Request-Id response header and error details first.400 invalid parameters, 401 missing or invalid API key, 403 insufficient balance/quota or missing model permission, 429 rate limit exceeded, 503 service temporarily unavailable, 500 / 502 transient server error.