Text-to-Speech

Convert text into spoken audio, compatible with the OpenAI Audio Speech API. Example models include gemini-2.5-flash-preview-tts, gemini-2.5-pro-preview-tts, and gemini-3.1-flash-tts-preview — see the model square for the full list and pricing.

Create Speech

POST https://apicdn.xyc.ai/v1/audio/speech
curl https://apicdn.xyc.ai/v1/audio/speech \
  -H "Authorization: Bearer sk-xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2.5-flash-preview-tts",
    "input": "Hello, welcome to XycAi.",
    "voice": "alloy"
  }' \
  --output speech.wav
from openai import OpenAI

client = OpenAI(base_url="https://apicdn.xyc.ai/v1", api_key="sk-xxxxxxxx")

resp = client.audio.speech.create(
    model="gemini-2.5-flash-preview-tts",
    input="Hello, welcome to XycAi.",
    voice="alloy",
)
resp.stream_to_file("speech.wav")

The response body is the raw audio stream (audio/wav), which you can write directly to a file.

Request Parameters

ParameterTypeNotes
modelstringRequired. TTS model name
inputstringRequired. The text to synthesize
voicestringVoice name, e.g. alloy
response_formatstringOptional. Output format such as wav or mp3 (model dependent)
Output format

Gemini TTS models return 24 kHz / 16-bit mono PCM WAV by default. Billing is per token at the upstream official rate, with your account's vendor discount applied automatically.