Text-to-Speech (TTS)¶
Convert text to natural-sounding speech audio.
Endpoint: POST /api/v1/audio/tts/generations
Auth: Required
Request Body¶
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
input |
string |
Yes | — | Text to convert to speech |
model |
string |
No | tts-1 |
TTS model ID |
provider |
string |
No | openai |
Provider name |
voice |
string |
No | — | Voice selection |
instructions |
string |
No | — | Voice control instructions |
response_format |
string |
No | mp3 |
Audio format |
speed |
float |
No | 1.0 |
Speed (0.25–4.0) |
additional_params |
object |
No | {} |
Provider-specific parameters |
byok_api_key |
string |
No | — | Your own provider API key |
Available Voices (OpenAI)¶
alloy, echo, fable, onyx, nova, shimmer
Audio Formats¶
mp3, opus, aac, flac, wav, pcm
Examples¶
import requests
response = requests.post(
"https://api.indoxhub.com/api/v1/audio/tts/generations",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "openai/tts-1",
"input": "Welcome to IndoxHub, the unified AI gateway.",
"voice": "nova",
"response_format": "mp3",
"speed": 1.0
}
)
result = response.json()
print(result["data"])
const response = await fetch("https://api.indoxhub.com/api/v1/audio/tts/generations", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "openai/tts-1",
input: "Welcome to IndoxHub, the unified AI gateway.",
voice: "nova",
response_format: "mp3"
})
});
const data = await response.json();
console.log(data.data);
Response¶
{
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"created_at": "2026-04-07T12:00:00Z",
"duration_ms": 2100.0,
"provider": "openai",
"model": "tts-1",
"success": true,
"message": "",
"data": { "audio_url": "..." },
"usage": {
"tokens_prompt": 0,
"tokens_completion": 0,
"tokens_total": 0,
"cost": 0.015,
"latency": 2100.0
}
}