Docs Native format /v1beta/models/gemini-2.5-flash-preview-tts:generateContent
API reference

TTS text to speech

Official documentation: https://ai.google.dev/gemini-api/docs/image-generation?hl=zh-cngemini-image-editing

POST/v1beta/models/gemini-2.5-flash-preview-tts:generateContent

Body Parametersapplication/json

contents* array

Conversation contents; TTS usually needs one user message with text to speak in parts

items
object object

Single-turn content (role defaults to user)

generationConfig* object

Generation config; TTS must declare AUDIO modality and configure voice

properties
responseModalities* array

Response modalities; for TTS use ["AUDIO"]

speechConfig object

Speech synthesis config; voice and pronunciation options

Responses

200 application/json
response-200 object
400 Bad request or validation failed application/json
response-400 object
properties
error* object
401 Missing or invalid API Key application/json
response-401 object
Request Body Example
1{
2"contents": [
3{
4"parts": [
5{
6"text": "说出,我是谁,谁是我"
7}
8]
9}
10],
11"generationConfig": {
12"responseModalities": [
13"AUDIO"
14],
15"speechConfig": {
16"voiceConfig": {
17"prebuiltVoiceConfig": {
18"voiceName": "Kore"
19}
20}
21}
22},
23"model": "gemini-2.5-flash-preview-tts"
24}
Code Sample cURL
1curl -X POST "https://api.digislash.com/v1beta/models/gemini-2.5-flash-preview-tts:generateContent" \
2-H "Authorization: Bearer <API Key>" \
3-H "Content-Type: application/json" \
4-d '{
5"contents": [
6{
7"parts": [
8{
9"text": "说出,我是谁,谁是我"
10}
11]
12}
13],
14"generationConfig": {
15"responseModalities": [
16"AUDIO"
17],
18"speechConfig": {
19"voiceConfig": {
20"prebuiltVoiceConfig": {
21"voiceName": "Kore"
22}
23}
24}
25},
26"model": "gemini-2.5-flash-preview-tts"
27}'
Response
1▼{
2"id": "resp_example",
3"object": "response",
4"status": "completed"
5}