AGTCloud API Docs
GuidesAPI ReferenceIntegrations and resourcesUpdate and help
AudioGemini TTS

Speech synthesis (Generate Content)

Synthesize speech with Generate Content, including voice settings, delivery style and two-speaker dialogue.

Convert text to speech in Generate Content format and return complete JSON with Base64 audio. Set the model ID in the request path; see the Gemini TTS model guide. For streaming, use Interactions.

POST/v1beta/models/{model}:generateContent

Convert text to single-speaker narration or two-speaker dialogue and return a complete JSON result.

Authorization

bearerAuth
AuthorizationBearer <token>

Use Bearer your-api-key in the Authorization Header.

In: header

Path Parameters

model*string

Enter an enabled model ID. See the Gemini TTS model guide for available models.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

Text, voices and dialogue

FieldUsage
contents[].parts[].textText to read aloud; put tone, emotion or accent instructions in the segment's speech_metadata.style
speechConfig.voiceConfig.voiceChoose a voice such as Kore for one speaker; do not combine with multiSpeakerVoiceConfig
speechConfig.multiSpeakerVoiceConfigSet each speaker's name and voiceConfig.voice in speakerVoiceConfigs, up to 2 speakers
speech_metadata.speakerRequired for each dialogue text segment; must match speakerVoiceConfigs[].speaker; segments are read in parts order
Vocal effects and pausesPut tags such as <laugh>, <sigh> and <short pause> in the text; use speech_metadata.style for sustained delivery instructions

The speechConfig above is inside generationConfig. Switch request examples between single speaker, style control, dialogue and PCM audio.

Output and playback

Field or formatHandling
candidates[].content.parts[].inlineDataTraverse the audio segments and decode Base64 data according to mimeType; audio is not returned as a download URL
Default formatWAV, 24 kHz, mono, 16-bit; save as .wav without adding another header
generationConfig.responseFormat.audiomimeType accepts AUDIO_WAV, AUDIO_L16, AUDIO_MULAW or AUDIO_ALAW; sampleRate sets the output rate in Hz, default 24000
Raw audioPlay PCM16 little-endian using its sample rate and channel count, or wrap it in WAV; Mu-law and A-law require their corresponding decoders
Usage and completionusageMetadata reports token usage; check finishReason to distinguish normal completion from content filtering and other stop reasons

Try It provides audio playback and download after the response completes, with complete JSON on the right. Raw PCM and G.711 audio are converted to WAV for playback.

Official references