gemini-tts text-to-speech
Official documentation: https://ai.google.dev/gemini-api/docs/text-generation?hl=zh-cnmulti-turn-conversations
POST
/v1beta/models/gemini-2.5-pro-preview-tts:generateContentBody Parametersapplication/json
contents* array
Conversation contents; provide text to speak in parts.text
items object object
Single-turn content
generationConfig* object
Generation config; must include AUDIO modality and voice config
properties responseModalities* array
Response modalities; for TTS use ["AUDIO"]
speechConfig* object
Speech synthesis configuration
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
1{
2"contents": [
3{
4"parts": [
5{
6"text": "Say cheerfully: Have a wonderful day!"
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}
1curl -X POST "https://api.digislash.com/v1beta/models/gemini-2.5-pro-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": "Say cheerfully: Have a wonderful day!"
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}'
1▼{
2▼"candidates": [
3▶{ 4 keys }
4],
5"modelVersion": "gemini-2.5-pro-preview-tts",
6▼"promptFeedback": {
7"safetyRatings": []
8},
9"responseId": "nXxoaf7mPM6j_uMPyICzkQo",
10▼"usageMetadata": {
11"candidatesTokenCount": 51,
12"promptTokenCount": 9,
13▶"promptTokensDetails": [ 1 items ],
14"thoughtsTokenCount": 0,
15"totalTokenCount": 60
16}
17}
