AGTCloud API Docs
GuidesAPI ReferenceIntegrations and resourcesUpdate and help
AudioGemini TTS

Speech synthesis (Interactions)

Synthesize single- or two-speaker speech with Interactions, including style control and streaming.

Convert the specified text to speech and return Base64 audio in complete JSON or SSE streaming. For model IDs, see the Gemini TTS model guide.

POST/v1beta/interactions

Convert text to audio with single-speaker narration, two-speaker dialogue and SSE streaming.

Authorization

bearerAuth
AuthorizationBearer <token>

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

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

Text, voices and dialogue

FieldUsage
inputPass a string for simple narration; use text blocks in a user_input step for style or speaker control
annotationsUse a type: "speech_metadata" annotation on each text block to set style and speaker; keep style instructions out of the text to be spoken
generation_config.speech_configUse [{"voice":"Kore"}] for one speaker; use a speakers object to assign voices for dialogue
speakerRequired on each dialogue text block; must exactly match speakers[].speaker; configure up to 2 speakers
Vocal effects and pausesUse tags such as <laugh>, <sigh> and <short pause> in the text; put sustained delivery instructions in style

Output and playback

Mode or settingHandling
Non-streaming responseTraverse steps, read the type: "audio" items in content of type: "model_output" steps and decode data; do not assume the first step contains audio
Default formatNon-streaming WAV, 24 kHz, mono, 16-bit; save or play directly without adding another WAV header
response_formatmime_type accepts audio/wav, audio/l16, audio/mulaw or audio/alaw; sample_rate is in Hz, defaults to 24000, and also accepts 16000 or 8000
stream: trueSSE defaults to raw PCM16 little-endian audio. Decode each step.delta → delta.data separately, then concatenate the bytes in order; do not concatenate Base64 strings
Usage and completionRead final usage from interaction.usage in interaction.completed; treat an error event as failure, not partial audio as a complete result

Try It provides audio playback and download after the response completes, with the original JSON or SSE on the right. Raw PCM and G.711 audio are converted to WAV for playback; the original response is preserved.

Usage notes

ItemDetails
Input and capabilitiesText input and audio output; no tool calls or web search
Background settingsRequests return generation results directly; background and webhook_config are ignored, while agent returns a parameter error
Audio durationControl duration through text length; max_output_tokens does not truncate audio. Split long text into paragraphs and allow a client timeout of at least 300 seconds

Official references