- Gemini TTS via Chat Completions - Use Gemini TTS models through the chat completions endpoint with
speech_configor OpenAI-compatibleaudioparameter (maps to Vertex AI API) - Cloud Text-to-Speech API - Use the OpenAI-compatible
/audio/speechendpoint for Chirp and Gemini TTS voices (maps to Cloud Text-to-Speech API)
Method 1: Gemini TTS via Chat Completions
This method uses the Vertex AI generateContent API internally and provides granular control over speech synthesis usingspeech_config or the OpenAI-compatible audio parameter.
Available Models
Using speech_config (Vertex AI Native)
Since
speech_config is not part of the OpenAI API specification:- Python SDK: Use
extra_bodyparameter to pass provider-specific parameters - Node.js SDK: Pass additional parameters directly - the Portkey SDK accepts arbitrary parameters via its flexible type definitions
Using audio Parameter (OpenAI-Compatible)
For a simpler, OpenAI-compatible interface, use the audio parameter:
Response Format
The audio is returned in the response as base64-encoded PCM 16-bit 24kHz audio:Multi-Speaker Synthesis
Generate conversations with multiple speakers usingmulti_speaker_voice_config:
Method 2: Cloud Text-to-Speech API
This method uses Google’s Cloud Text-to-Speech API through the OpenAI-compatible/audio/speech endpoint. It supports both Gemini TTS and Chirp voices with more audio encoding options.
Basic Usage
With Style Instructions
Use theinstructions parameter to control the speaking style:
Supported Audio Formats
Voice Options
Gemini TTS offers 30 distinct voices:Supported Languages
Gemini TTS supports 24+ languages in GA and 50+ in Preview. Common GA languages include:Choosing the Right Method
When to Use Vertex AI API (Chat Completions)
- You need temperature control for creative/diverse output
- You want multi-speaker conversations
- You’re already using Vertex AI for other models
- You need streaming audio output
When to Use Cloud TTS API (Audio Speech)
- You need specific audio encoding formats (MP3, WAV, etc.)
- You want a simpler OpenAI-compatible interface
- You’re migrating from OpenAI TTS
- You need to stream text input in multiple chunks
Prompting Tips
For detailed prompting strategies, see Google’s prompting tips.Style Prompts
Control the speaking style through your message content:Markup Tags (Preview)
Use bracketed tags for specific effects:
Example:
Limits
If input text results in audio longer than 655 seconds, the audio will be truncated.

