About
Gemini 2.5 Pro Preview TTS is the Gemini 2.5 Pro text-to-speech preview model. Delivery directions are written into the text ("Say cheerfully: ..."): Infron sends instructions in front of the input in that form. It offers 30 prebuilt voices and two-speaker dialogue; custom voices are not available. Infron serves it through the OpenAI-compatible POST /v1/audio/speech endpoint and returns 24 kHz mono 16-bit audio as wav or pcm, with optional streaming. A request takes up to 8,192 input tokens and is billed per text input token and audio output token.
1. Calling the API
Setup your API Key
To begin using Infron, create an account and generate your API Key.
export INFRON_KEY="YOUR_API_KEY"
Submit a request
Send JSON to POST https://llm.onerouter.pro/v1/audio/speech with your Infron API key. The request and response follow the OpenAI speech API, so the OpenAI SDKs work with the base URL https://llm.onerouter.pro/v1. The examples use the Google voice Kore. Replace YOUR_API_KEY with your key.
curl
curl https://llm.onerouter.pro/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "google/gemini-2.5-pro-preview-tts/text-to-audio",
"voice": "Kore",
"input": "Hello! Welcome to Infron.",
"response_format": "wav"
}' \
--output speech.wav
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://llm.onerouter.pro/v1",
api_key="YOUR_API_KEY",
)
with client.audio.speech.with_streaming_response.create(
model="google/gemini-2.5-pro-preview-tts/text-to-audio",
voice="Kore",
input="Hello! Welcome to Infron.",
response_format="wav",
) as response:
response.stream_to_file("speech.wav")
TypeScript (OpenAI SDK)
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://llm.onerouter.pro/v1",
apiKey: "YOUR_API_KEY",
});
const response = await client.audio.speech.create({
model: "google/gemini-2.5-pro-preview-tts/text-to-audio",
voice: "Kore",
input: "Hello! Welcome to Infron.",
response_format: "wav",
});
fs.writeFileSync("speech.wav", Buffer.from(await response.arrayBuffer()));
Response
A successful request returns HTTP 200 with the audio file as the body, not JSON. Content-Type follows response_format: audio/wav for wav, audio/pcm for pcm. The examples above save it as speech.wav.
Streaming
Add "stream_format": "sse" to receive Server-Sent Events while the audio is generated. Each speech.audio.delta event carries the next base64 chunk of the audio in response_format; decode the chunks and append them in order. The stream ends with a speech.audio.done event that reports usage.
curl https://llm.onerouter.pro/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "google/gemini-2.5-pro-preview-tts/text-to-audio",
"voice": "Kore",
"input": "Hello! Welcome to Infron.",
"response_format": "wav",
"stream_format": "sse"
}' \
--no-buffer
data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}
data: {"type":"speech.audio.delta","audio":"<base64 audio chunk>"}
data: {"type":"speech.audio.done","usage":{"input_tokens":9,"output_tokens":52,"total_tokens":61}}
The usage values are an example.
Routing and usage
This model is served by google-ai-studio (Google AI Studio). Billing uses the text input tokens and audio output tokens that Google reports. The audio response carries no usage; with streaming, speech.audio.done reports the text tokens as usage.input_tokens and the audio tokens as usage.output_tokens.
Errors
Parameters this model does not accept are rejected with HTTP 400 before the request is sent to Google, and nothing is charged. error.message explains the problem and ends with the request ID:
{
"error": {
"message": "speed is not supported by this model; describe the pace in instructions instead (request id: 20261111221810441285700pZnPkvCJ)",
"type": "infron_ai_error",
"param": "",
"code": "invalid_request_error"
}
}
Errors reported by Google, such as an unknown voice ID, are returned with Google's message. If a stream fails after it has started, an error event is sent instead of speech.audio.done.
2. Schema
Input
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
model | string | Yes | -- | google/gemini-2.5-pro-preview-tts/text-to-audio | Model ID. |
input | string | Yes | -- | Up to 8,192 input tokens | Text to speak; stage directions may be written into it. With multi_speaker_voice_config, write one Speaker: text line per turn. |
voice | string | No | -- | -- | Prebuilt voice name, for example Kore: Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, Sulafat. Custom voices (voice_..., voicekey_...) are rejected with 400. Omit it to let Google choose the voice. |
response_format | string | No | wav | wav, pcm | Audio format. Both are 24 kHz mono 16-bit; pcm is the same audio without the WAV header. |
instructions | string | No | -- | -- | Delivery direction, e.g. Say cheerfully. Sent in front of the input as <instructions>: <input>. |
stream_format | string | No | audio | audio, sse | sse streams Server-Sent Events (see Streaming). |
Google fields
These fields are not part of the OpenAI speech API. Put them at the top level of the JSON body; with the OpenAI Python SDK pass them in extra_body.
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
multi_speaker_voice_config | object | No | -- | 2 speakers | Two-speaker dialogue: speakerVoiceConfigs lists each speaker name with voiceConfig.prebuiltVoiceConfig.voiceName. Every input line starts with one of the speaker names (Joe: ...). Replaces voice. |
Two-speaker request
curl https://llm.onerouter.pro/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "google/gemini-2.5-pro-preview-tts/text-to-audio",
"input": "Joe: How is it going today, Jane?\nJane: Not too bad, how about you?",
"response_format": "wav",
"multi_speaker_voice_config": {
"speakerVoiceConfigs": [
{
"speaker": "Joe",
"voiceConfig": {
"prebuiltVoiceConfig": {
"voiceName": "Kore"
}
}
},
{
"speaker": "Jane",
"voiceConfig": {
"prebuiltVoiceConfig": {
"voiceName": "Puck"
}
}
}
]
}
}' \
--output dialogue.wav
Unsupported fields
| Field | Behavior |
|---|---|
speed | Rejected with 400 unless it is 1. Describe the pace in instructions. |
language | Rejected with 400. Google detects the input language. |
sample_rate | Rejected with 400. Output is always 24 kHz. |
bit_rate, text_normalization | Ignored. |
| Other fields | Not forwarded to Google. |
Output
| Parameter | Type | Range | Description |
|---|---|---|---|
| Response body | binary | wav, pcm | The audio file in response_format (without stream_format=sse). |
Content-Type header | string | audio/wav, audio/pcm | MIME type of the audio. |
X-Audio-Sample-Rate header | integer | 24000 | Sample rate of pcm output. |
type | string | speech.audio.delta, speech.audio.done, error | Streaming event type. |
audio | string | Base64 | Next chunk of the audio (speech.audio.delta). |
usage.input_tokens | integer | Non-negative | Text input tokens (speech.audio.done). |
usage.output_tokens | integer | Non-negative | Audio output tokens. |
usage.total_tokens | integer | Non-negative | Sum of input and output. |
error | object | -- | message, type and code of a failure (error event). |
3. Detailed Pricing
| Model | Endpoint | Billing unit | Input (text) | Output (audio) |
|---|---|---|---|---|
| Google: Gemini 2.5 Pro Preview TTS | google-ai-studio | Per 1M tokens | $1.00 | $20.00 |
Prices are in USD. Billing uses the text input tokens and audio output tokens that Google reports.
Sources: Speech generation, Models, Pricing.