Skip to main content
Google Vertex AI offers powerful text-to-speech capabilities through Gemini TTS models. Portkey supports two approaches for TTS:
  1. Gemini TTS via Chat Completions - Use Gemini TTS models through the chat completions endpoint with speech_config or OpenAI-compatible audio parameter (maps to Vertex AI API)
  2. Cloud Text-to-Speech API - Use the OpenAI-compatible /audio/speech endpoint 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 using speech_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_body parameter 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 using multi_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 the instructions 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.

Portkey is now PRISMA AIRS AI Gateway. See it in action.

Contact Us
Last modified on August 3, 2026