Gemini 3.1 Flash TTS Serverless API

Expressive, controllable TTS with 70+ language support.

 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/gemini-3.1-flash-tts"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "text": "Welcome to Segmind — the fastest API platform for AI image and video generation. Explore hundreds of models, build powerful workflows, and ship your ideas in minutes.",
12    "voice_1": "Kore",
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-3.1-flash-tts

Parameters

textrequired
string

Input text to convert to speech. Supports audio tags for style control. Use natural language prompts for expressive results.

Default: "Welcome to Segmind — the fastest API platform for AI image and video generation. Explore hundreds of models, build powerful workflows, and ship your ideas in minutes."
temperatureoptional
number

Expressiveness level (0.0–2.0). Use 0.2–0.5 for professional narration; 0.8–1.4 for emotional delivery.

Default: 0.4Range: 0 - 2
voice_1optional
string

Primary speaker voice name. Options: Kore, Puck, Charon, Aoede, Fenrir, Zephyr. Kore is neutral and professional.

Default: "Kore"
voice_2optional
string

Second speaker voice for multi-character dialogue. Leave empty for single-speaker. Max 2 speakers supported.

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