Gemini TTS 2.5 Flash Serverless API

Gemini 2.5 TTS transforms text into lifelike speech with expressive tones and consistent character voices.

~18.40s
~$0.005
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/gemini-2.5-flash-tts"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "text": "Narrator: Imagine the future with endless possibilities!",
12    "voice_1": "Zephyr",
13    "temperature": 0.4
14}
15
16response = requests.post(url, headers=headers, json=data)
17
18if response.status_code == 200:
19    result = response.json()
20    print(json.dumps(result, indent=2))
21else:
22    print(f"Error: {response.status_code}")
23    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/gemini-2.5-flash-tts

Parameters

textrequired
string

Input text for speech synthesis using natural prompts. Use clear labels and styles for expressive audio.

temperatureoptional
number

Adjusts speech creativity. Use 0.4 for reliable, steady expression or 0.7 for dynamic, lively speech.

Default: 0.4Range: 0 - 2
voice_1optional
string

Select the primary speaker's voice. Try 'Kore' for a warm tone or 'Zephyr' for a breezy effect.

Default: "Zephyr"
Allowed values (30 total):
"Zephyr""Puck""Charon""Kore""Fenrir""Leda""Orus""Aoede""Callirrhoe""Autonoe"+20 more
voice_2optional
string

Optional second speaker voice for dialogues. Choose a distinct voice, e.g., 'Fenrir' for deeper bass.

Default: null
Allowed values (30 total):
"Zephyr""Puck""Charon""Kore""Fenrir""Leda""Orus""Aoede""Callirrhoe""Autonoe"+20 more

Response Type

Returns: Audio

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out