API Documentation
Integrate text-to-speech into your applications with our REST API. Access 17 TTS engines, 400+ voices, and voice cloning.
API Features
- ✓ 17 TTS engines
- ✓ 400+ voices
- ✓ Voice cloning
- ✓ 40+ languages
- ✓ MP3, WAV, OGG
Contents
Base URL
https://api.texttospeechai.com/v1/
Authentication
All API requests require a Bearer token in the Authorization header.
Getting Your API Token
- Log in to your account dashboard
- Navigate to API Settings
- Generate a new API token
Request Header
Authorization: Bearer YOUR_API_TOKEN
Example (cURL)
curl -X GET "https://api.texttospeechai.com/v1/account/" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Rate Limits
API requests are limited based on your account tier:
| Tier | Requests/Day |
|---|---|
| Free | 100 |
| Premium | 1,000 |
| Enterprise | 10,000 |
Rate limits reset at midnight UTC. Check the X-RateLimit-* headers in API responses.
Generate Speech
Create a new text-to-speech generation request.
POST
/v1/generate/
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string | Yes | Text to synthesize (max 5000 chars) |
voice |
string | Yes | Voice slug (e.g., "en_US-lessac-medium") |
speed |
float | No | Speaking speed 0.5-2.0 (default 1.0) |
pitch |
float | No | Pitch adjustment 0.5-2.0 (default 1.0) |
format |
string | No | Output format: mp3, wav, ogg (default mp3) |
Example Request
curl -X POST "https://api.texttospeechai.com/v1/generate/" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, welcome to TextToSpeechAI!",
"voice": "en_US-lessac-medium",
"speed": 1.0,
"format": "mp3"
}'
Response
{
"uuid": "abc123-def456-...",
"status": "pending",
"text_length": 35,
"voice": "en_US-lessac-medium",
"credits_used": 0.35,
"estimated_time": 5
}
List Voices
Get available voices with optional filtering.
GET
/v1/voices/
Query Parameters
| Parameter | Description |
|---|---|
language |
Filter by language code (e.g., "en") |
gender |
Filter by gender (male/female/neutral) |
model_type |
Filter by TTS engine (piper, bark, f5tts, etc.) |
page |
Page number (default 1) |
per_page |
Results per page (default 50, max 100) |
Example Request
curl "https://api.texttospeechai.com/v1/voices/?language=en&gender=female" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Check Status
Check the status of a generation request.
GET
/v1/status/{uuid}/
Status Values
pending- Request queued for processingprocessing- Currently generating audiocompleted- Audio ready for downloadfailed- Generation failed (see error field)
Response (Completed)
{
"uuid": "abc123-def456-...",
"status": "completed",
"audio_url": "https://texttospeechai.com/uploads/generations/...",
"duration_seconds": 2.5,
"processing_time_ms": 1200
}
Voice Cloning
Create a cloned voice from reference audio.
POST
/v1/clone/
Request (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Name for the cloned voice |
audio |
file | Yes | Reference audio (WAV/MP3, 6-60 seconds) |
language |
string | No | Language code (default "en") |
Example Request
curl -X POST "https://api.texttospeechai.com/v1/clone/" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "name=My Custom Voice" \
-F "audio=@reference.wav" \
-F "language=en"
Account Info
Get account information and credit balance.
GET
/v1/account/
Response
{
"email": "user@example.com",
"credits": 1000.00,
"created_at": "2024-01-01T00:00:00Z",
"rate_limit": {
"limit": 100,
"remaining": 95,
"used": 5,
"resets_at": "2024-01-02T00:00:00Z"
}
}
Error Codes
| Code | Description |
|---|---|
400 |
Bad Request - Invalid parameters |
401 |
Unauthorized - Invalid or missing API token |
402 |
Payment Required - Insufficient credits |
404 |
Not Found - Resource not found |
429 |
Too Many Requests - Rate limit exceeded |
500 |
Internal Server Error |
Error Response Format
{
"error": "error_description"
}
Frequently Asked Questions
Sign up for a free account, then go to your Account Settings and click "Generate API Token". Your token will be displayed once - save it securely. You can regenerate it anytime if needed.
Free accounts get 1,000 credits to start (API access requires a paid plan). Pro plan ($19/mo) includes 1,000 requests/day, Business ($49/mo) includes 10,000 requests/day with priority processing.
All 17 TTS engines are available: Piper, VITS, and MeloTTS for fast generation, Bark, F5-TTS, Parler, and Kokoro for premium quality, StyleTTS2, Tortoise, OpenVoice, and Chatterbox for highest quality, plus CosyVoice2, GPT-SoVITS, Dia, Qwen3-TTS, Zonos, and Pocket TTS for the latest AI voice synthesis. Choose based on your speed vs quality requirements.
Upload a reference audio file (6-60 seconds) via the
/v1/clone/ endpoint. We'll create a cloned voice that you can use in future generations. Cloned voices work across multiple languages - clone once, generate in any supported language.
The API outputs MP3, WAV, and OGG formats. Specify your preferred format in the
format parameter. For voice cloning input, we accept WAV and MP3 reference audio.
Depends on the model: Piper/VITS: ~1-2 seconds, Bark/F5-TTS/Parler: ~5-15 seconds, StyleTTS2/Tortoise: ~15-60 seconds. Premium accounts get priority queue access for faster processing during peak times.
Yes! All API usage grants you full commercial rights to the generated audio. Use it in apps, games, videos, podcasts, IVR systems, or any commercial project. Enterprise plans include priority support and custom SLAs.
Code Examples
import requests
import time
API_KEY = "YOUR_API_TOKEN"
BASE_URL = "https://api.texttospeechai.com/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Generate speech
response = requests.post(
f"{BASE_URL}/generate/",
headers=headers,
json={
"text": "Hello, world!",
"voice": "en_US-lessac-medium",
"format": "mp3"
}
)
data = response.json()
uuid = data["uuid"]
# Poll for completion
while True:
status = requests.get(
f"{BASE_URL}/status/{uuid}/",
headers=headers
).json()
if status["status"] == "completed":
print(f"Audio URL: {status['audio_url']}")
break
elif status["status"] == "failed":
print(f"Error: {status['error']}")
break
time.sleep(2)
const API_KEY = 'YOUR_API_TOKEN';
const BASE_URL = 'https://api.texttospeechai.com/v1';
async function generateSpeech(text, voice) {
const response = await fetch(`${BASE_URL}/generate/`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: text,
voice: voice,
format: 'mp3'
})
});
const data = await response.json();
// Poll for completion
while (true) {
const status = await fetch(
`${BASE_URL}/status/${data.uuid}/`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
).then(r => r.json());
if (status.status === 'completed') {
return status.audio_url;
} else if (status.status === 'failed') {
throw new Error(status.error);
}
await new Promise(r => setTimeout(r, 2000));
}
}
// Usage
generateSpeech('Hello, world!', 'en_US-lessac-medium')
.then(url => console.log('Audio URL:', url))
.catch(err => console.error(err));
# Generate speech
curl -X POST "https://api.texttospeechai.com/v1/generate/" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "Hello, world!", "voice": "en_US-lessac-medium"}'
# Check status (replace UUID)
curl "https://api.texttospeechai.com/v1/status/abc123-def456/" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# List voices
curl "https://api.texttospeechai.com/v1/voices/?language=en" \
-H "Authorization: Bearer YOUR_API_TOKEN"
Ready to Build?
Get your free API key and start generating speech in minutes. 500 free credits included.
Create Free AccountNo credit card required. 100 API requests/day free.