API Documentation
Integrate TTS.ai into your applications with our REST API. OpenAI-compatible format for easy migration.
Overview
The TTS.ai API provides programmatic access to all platform features: text-to-speech synthesis, speech-to-text transcription, voice cloning, audio enhancement, and more. The API uses standard REST conventions with JSON request/response bodies.
API Key
Get your API key from Account Settings. Available on all plans, including free accounts.
Base URL
https://api.tts.ai/v1/
Auth
Bearer token via Authorization header
Authentication
/v1/tts/ work without any auth, up to 5,000 characters/day per IP, using any of our free models (piper, vits, melotts, kokoro). Sign up for a free account to get 15,000 bonus characters and access to premium models.
For premium models and higher rate limits, authenticate with a Bearer token in the Authorization header.
Authorization: Bearer sk-tts-your-api-key-here
SDKs
Official SDKs make it easy to integrate TTS.ai into your application. Both are open source and available on GitHub.
Python
pip install ttsai
from tts_ai import TTSClient
client = TTSClient(api_key="sk-tts-...")
audio = client.generate(
text="Hello world!",
model="kokoro"
)
client.save(audio, "output.wav")
JavaScript / Node.js
npm install @ttsainpm/ttsai
const { TTSClient } = require('@ttsainpm/ttsai');
const client = new TTSClient({
apiKey: 'sk-tts-...'
});
const audio = await client.generate({
input: 'Hello world!',
model: 'kokoro'
});
await client.saveToFile(audio, 'output.wav');
Base URL
All endpoints are relative to this base URL. For example, the TTS endpoint is:
Rate Limits
API rate limits vary by plan:
| Plan | Requests/min | Concurrent | Max Text Length |
|---|---|---|---|
| Free | 10 | 2 | 500 chars |
| Starter | 30 | 3 | 100,000 chars |
| Pro | 60 | 5 | 100,000 chars |
| Business+ | 300 | 20 | 50,000 chars |
Rate limit headers are included in every response: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
Character Usage
| Service | Cost | Unit |
|---|---|---|
| TTS (Free models: Piper, VITS, MeloTTS) | 1,000 characters | per 1,000 characters |
| TTS (Standard models: Kokoro, CosyVoice 2, etc.) | 2,000 characters | per 1,000 characters |
| TTS (Premium models: Tortoise, Chatterbox, etc.) | 4,000 characters | per 1,000 characters |
| Speech to Text | 2,000 characters | per minute of audio |
| Voice Cloning | 4,000 characters | per 1,000 characters |
| Voice Changer | 3,000 characters | per minute of audio |
| Audio Enhancement | 2,000 characters | per minute of audio |
| Vocal Removal / Stem Splitting | 3,000-4,000 characters | per minute of audio |
| Speech Translation | 5,000 characters | per minute of audio |
| Voice Chat | 3,000 characters | per turn |
| Key & BPM Finder | Free | -- |
| Audio Converter | Free | -- |
Text to Speech
Convert text to speech audio. Returns audio file in the requested format.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | No | Model ID (e.g., kokoro, chatterbox, piper). If omitted, we auto-pick a model that supports the requested language — kokoro for en/ja/zh/ko/fr/de/it/pt/es/hi/ru, piper for other supported languages (ar/pl/nl/cs/da/fi/el/hu/tr/uk/vi/etc.). |
| text | string | Yes | Text to convert to speech (max 100,000 chars per request) |
| voice | string | Yes | Voice ID (use /v1/voices/ to list available voices) |
| format | string | No | Output format: mp3 (default), wav, flac, ogg |
| speed | float | No | Speaking speed multiplier. Default: 1.0. Range: 0.5 to 2.0 |
| language | string | No | Language code (e.g., en, es). Auto-detected if omitted. |
| stream | boolean | No | Enable streaming response. Default: false |
Example Request
curl -X POST https://api.tts.ai/v1/tts/ \
-H "Authorization: Bearer sk-tts-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "kokoro",
"text": "Hello from TTS.ai! This is a test.",
"voice": "af_bella",
"format": "mp3"
}' \
--output output.mp3
Response
The TTS endpoint queues your request and returns a JSON response with a job UUID. You then poll for the result.
Step 1: Submit request
{
"uuid": "77b71db532874ce98e84a69a2d740d4c",
"job_id": "f21316bb-aefa-480d-8523-701d1e3184ce",
"status": "queued",
"credits_used": 11,
"credits_remaining": 15000
}
Step 2: Poll for result
Poll this endpoint every 1-2 seconds until status is completed or failed.
{
"status": "completed",
"result_url": "https://api.tts.ai/static/downloads/77b71db5.../output.mp3"
}
{
"status": "processing"
}
Step 3: Download audio
Fetch the result_url from the completed response to download the audio file.
Full example
import requests, time
API_KEY = "sk-tts-your-key"
BASE = "https://api.tts.ai"
# 1. Submit TTS request
resp = requests.post(f"{BASE}/v1/tts/", json={
"model": "kokoro",
"text": "Hello from TTS.ai!",
"voice": "af_bella"
}, headers={"Authorization": f"Bearer {API_KEY}"})
data = resp.json()
uuid = data["uuid"]
# 2. Poll for result
while True:
result = requests.get(f"{BASE}/v1/speech/results/",
params={"uuid": uuid}).json()
if result["status"] == "completed":
# 3. Download audio
audio = requests.get(result["result_url"])
with open("output.mp3", "wb") as f:
f.write(audio.content)
break
elif result["status"] == "failed":
raise Exception(result.get("error", "Generation failed"))
time.sleep(1.5)
Streaming alternative: For supported models (Kokoro, MeloTTS), use POST /v1/tts/stream/ for real-time Server-Sent Events (SSE) streaming — no polling needed.
Speech to Text
Transcribe audio to text. Supports 99 languages with auto-detection.
Request Body (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Audio file (MP3, WAV, FLAC, OGG, M4A, MP4, WebM). Max 100MB. |
| model | string | No | STT model: whisper (default), faster-whisper, sensevoice |
| language | string | No | Language code. auto for auto-detection (default). |
| timestamps | boolean | No | Include word-level timestamps. Default: false |
| diarize | boolean | No | Enable speaker diarization. Default: false |
Response
{
"text": "Hello, this is a transcription test.",
"language": "en",
"duration": 3.5,
"segments": [
{
"start": 0.0,
"end": 1.8,
"text": "Hello, this is",
"speaker": "SPEAKER_00"
},
{
"start": 1.8,
"end": 3.5,
"text": "a transcription test.",
"speaker": "SPEAKER_00"
}
]
}
Voice Cloning
Generate speech in a cloned voice. Upload a reference audio and text.
Request Body (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
| reference_audio | file | Yes | Reference voice audio (10-30 seconds recommended). Max 20MB. |
| text | string | Yes | Text to speak in the cloned voice. |
| model | string | No | Clone model: chatterbox (default), cosyvoice2, gpt-sovits |
| format | string | No | Output format: mp3 (default), wav, flac |
| language | string | No | Target language code. Must be supported by the chosen model. |
Response
Returns the audio file as binary data, same as the TTS endpoint.
Voice Changer
Convert audio to sound like a different voice. Upload source audio and choose a target voice.
Request Body (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Source audio file (MP3, WAV, FLAC). Max 50MB. |
| target_voice | string | Yes | Target voice ID to convert to (use /v1/voices/ to list available voices) |
| model | string | No | Voice conversion model: openvoice (default), knn-vc |
| format | string | No | Output format: wav (default), mp3, flac |
Example Request
curl -X POST https://api.tts.ai/v1/voice-convert/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "file=@source_audio.mp3" \
-F "target_voice=af_bella" \
-F "model=openvoice" \
-o converted.wav
Response
Returns the converted audio file as binary data.
Speech Translation
Translate spoken audio from one language to another. Combines speech-to-text, translation, and text-to-speech in a single call.
Request Body (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Source audio file in the original language. Max 100MB. |
| target_language | string | Yes | Target language code (e.g., es, fr, de, ja) |
| voice | string | No | Voice for translated output. Auto-selected if omitted. |
| preserve_voice | boolean | No | Attempt to preserve the original speaker's voice characteristics. Default: false |
Response
{
"original_text": "Hello, how are you?",
"translated_text": "Hola, como estas?",
"source_language": "en",
"target_language": "es",
"audio_url": "https://api.tts.ai/v1/results/translate_abc123.mp3",
"credits_used": 5
}
Speech to Speech
Transform speech style, emotion, or delivery while keeping the content. Useful for adjusting tone, pacing, and expressiveness.
Request Body (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Source speech audio file. Max 50MB. |
| voice | string | Yes | Target voice ID for the output speech |
| model | string | No | Model: openvoice (default), chatterbox |
| emotion | string | No | Target emotion: neutral, happy, sad, angry, excited |
| speed | float | No | Speed adjustment. Default: 1.0. Range: 0.5 to 2.0 |
Response
Returns the transformed audio file as binary data.
Audio Tools
Audio processing endpoints for enhancement, vocal removal, stem splitting, and more.
Enhance audio quality: denoise, improve clarity, super resolution.
| file file | Audio file to enhance |
| denoise boolean | Enable denoising (default: true) |
| enhance_clarity boolean | Enhance speech clarity (default: true) |
| super_resolution boolean | Upscale audio quality (default: false) |
| strength integer | 1-3 (light, medium, strong). Default: 2 |
Separate vocals from instrumentals (vocal removal) or split into stems.
| file file | Audio file to separate |
| model string | demucs (default) or spleeter |
| stems integer | Number of stems: 2, 4, 5, or 6 (default: 2) |
| format string | Output format: wav, mp3, flac |
Remove echo and reverb from audio recordings.
| file file | Audio file to process |
| type string | echo or reverb (default: both) |
| intensity integer | 1-5 (default: 3) |
Analyze audio to detect key, BPM, and time signature.
| file file | Audio file to analyze |
{
"key": "C",
"scale": "Major",
"bpm": 120.0,
"time_signature": "4/4",
"camelot": "8B",
"compatible_keys": ["C Major", "G Major", "F Major", "A Minor"]
}
Convert audio between formats.
| file file | Audio file to convert |
| format string | Target format: mp3, wav, flac, ogg, m4a, aac |
| bitrate integer | Output bitrate in kbps: 64, 128, 192, 256, 320 |
| sample_rate integer | Sample rate: 22050, 44100, 48000 |
| channels string | mono or stereo |
Voice Chat
Send audio or text and receive an AI response with synthesized speech.
Request Body (multipart/form-data or JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
| audio | file | No* | Audio input (either audio or text required) |
| text | string | No* | Text input (either audio or text required) |
| voice | string | No | Voice for AI response. Default: af_bella |
| tts_model | string | No | TTS model for response. Default: kokoro |
| system_prompt | string | No | Custom system prompt for the AI |
| conversation_id | string | No | Continue an existing conversation |
Response
{
"conversation_id": "conv_abc123",
"user_text": "What is the capital of France?",
"ai_text": "The capital of France is Paris.",
"audio_url": "https://api.tts.ai/v1/audio/tmp/resp_xyz.mp3",
"credits_used": 3
}
Batch TTS
Submit multiple texts for parallel TTS generation. Optionally receive a webhook callback when all jobs complete.
Parameters
| Parameter | Type | Description |
|---|---|---|
| texts | array | Array of objects: {text, model, voice}. Max 50 items. |
| webhook_url | string | Optional URL to POST results when batch completes. |
Response
{
"batch_id": "abc123",
"total": 3,
"completed": 0,
"status": "processing"
}
Poll progress with GET /v1/tts/batch/result/?batch_id=abc123
Voice Embedding
Pre-compute a voice embedding from reference audio. Use the returned embed_id in subsequent voice cloning requests for near-instant generation.
Parameters
| Parameter | Type | Description |
|---|---|---|
| file | file | Reference audio file (WAV, MP3, FLAC). |
| model | string | Cloning model (default: chatterbox). Supported: chatterbox, cosyvoice2, openvoice, gpt-sovits, spark, indextts2, qwen3-tts. |
Response
{
"embed_id": "emb_abc123",
"model": "chatterbox",
"duration_ms": 450
}
Health Check
Check GPU server status, loaded models, and queue size. No authentication required. Cached for 30 seconds.
Response
{
"status": "online",
"latency_ms": 45,
"queue_size": 3,
"models_loaded": ["kokoro", "chatterbox", "cosyvoice2"]
}
List Models
Returns a list of all available models with their capabilities.
Response
{
"models": [
{
"id": "kokoro",
"name": "Kokoro",
"type": "tts",
"tier": "standard",
"languages": ["en", "ja", "ko", "zh", "fr"],
"supports_cloning": false,
"supports_streaming": true,
"credits_per_1k_chars": 2
},
{
"id": "chatterbox",
"name": "Chatterbox",
"type": "tts",
"tier": "premium",
"languages": ["en"],
"supports_cloning": true,
"supports_streaming": true,
"credits_per_1k_chars": 4
}
]
}
List Voices
Returns a list of all available voices, optionally filtered by model or language.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| model | string | Filter by model ID (e.g., kokoro) |
| language | string | Filter by language code (e.g., en) |
| gender | string | Filter by gender: male, female, neutral |
Response
{
"voices": [
{
"id": "af_bella",
"name": "Bella",
"model": "kokoro",
"language": "en",
"gender": "female",
"preview_url": "https://api.tts.ai/v1/voices/preview/af_bella.mp3"
}
],
"total": 142
}
Saved Voices (Persistent Clones)
Upload a reference audio once, get back a persistent voice_id, then reference that id in TTS requests instead of re-uploading audio every call. Ideal for high-volume integrations.
Upload a voice
POST
https://tts.ai/api/v1/user-voices/
Auth required
Multipart form. Fields: file (required, 5-30s audio), name (required), language (optional, default en), model (optional — auto-picks cosyvoice2 for zh/ja/ko else openvoice), consent_confirmed (required, any truthy value).
curl -X POST https://tts.ai/api/v1/user-voices/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "file=@reference.wav" \
-F "name=My Narrator" \
-F "language=en" \
-F "consent_confirmed=true"
# Response:
{
"public_id": "uv_a1b2c3d4e5f6",
"id": 42,
"name": "My Narrator",
"model_name": "openvoice",
"language": "en",
"reference_audio_url": "https://tts.ai/media/user-voices/....wav",
"storage_status": "active",
"created_at": "2026-04-17T03:45:00+00:00"
}
Use the saved voice in TTS
POST to /api/v1/tts/ (NOTE: web VPS host, not api.tts.ai) with user_voice_id. We load your stored audio and route to the cloning pipeline.
curl -X POST https://tts.ai/api/v1/tts/ \
-H "Authorization: Bearer sk-tts-your-key" \
-H "Content-Type: application/json" \
-d '{"text":"Hello from my saved voice","user_voice_id":"uv_a1b2c3d4e5f6"}'
# Returns a queued job — poll /v1/speech/results/?uuid=... for the audio URL.
List / delete
GET https://tts.ai/api/v1/user-voices/ # list your saved voices + quota info
DELETE https://tts.ai/api/v1/user-voices/?public_id=uv_a1b2c3d4e5f6
Archive / reactivate (free)
Archived voices stay in your account but can't be used in TTS. Useful for dormant end users so your list stays clean.
POST https://tts.ai/api/v1/user-voices/uv_a1b2c3d4e5f6/archive/
POST https://tts.ai/api/v1/user-voices/uv_a1b2c3d4e5f6/reactivate/
Code Examples
Text to Speech
import requests
API_KEY = "sk-tts-your-key"
# Text to Speech
response = requests.post(
"https://api.tts.ai/v1/tts/",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "kokoro",
"text": "Hello from TTS.ai!",
"voice": "af_bella",
"format": "mp3"
}
)
with open("output.mp3", "wb") as f:
f.write(response.content)
print(f"Credits used: {response.headers.get('X-Credits-Used')}")
Speech to Text
# Speech to Text
with open("recording.mp3", "rb") as f:
response = requests.post(
"https://api.tts.ai/v1/stt/",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"file": f},
data={"model": "faster-whisper", "timestamps": "true"}
)
result = response.json()
print(result["text"])
Voice Cloning
# Voice Cloning
with open("reference.wav", "rb") as ref:
response = requests.post(
"https://api.tts.ai/v1/tts/clone/",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"reference_audio": ref},
data={
"text": "This speech uses a cloned voice.",
"model": "chatterbox"
}
)
with open("cloned_output.mp3", "wb") as f:
f.write(response.content)
Text to Speech
const API_KEY = 'sk-tts-your-key';
// Text to Speech
const response = await fetch('https://api.tts.ai/v1/tts/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'kokoro',
text: 'Hello from TTS.ai!',
voice: 'af_bella',
format: 'mp3'
})
});
const audioBlob = await response.blob();
const audioUrl = URL.createObjectURL(audioBlob);
const audio = new Audio(audioUrl);
audio.play();
Speech to Text
// Speech to Text
const formData = new FormData();
formData.append('file', audioFile);
formData.append('model', 'faster-whisper');
const response = await fetch('https://api.tts.ai/v1/stt/', {
method: 'POST',
headers: { 'Authorization': `Bearer ${API_KEY}` },
body: formData
});
const result = await response.json();
console.log(result.text);
Text to Speech
# Text to Speech
curl -X POST https://api.tts.ai/v1/tts/ \
-H "Authorization: Bearer sk-tts-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"kokoro","text":"Hello!","voice":"af_bella","format":"mp3"}' \
-o output.mp3
Speech to Text
# Speech to Text
curl -X POST https://api.tts.ai/v1/stt/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "file=@recording.mp3" \
-F "model=faster-whisper" \
-F "timestamps=true"
Voice Cloning
# Voice Cloning
curl -X POST https://api.tts.ai/v1/tts/clone/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "reference_audio=@reference.wav" \
-F "text=This uses a cloned voice." \
-F "model=chatterbox" \
-o cloned.mp3
Audio Enhancement
# Audio Enhancement
curl -X POST https://api.tts.ai/v1/audio/enhance/ \
-H "Authorization: Bearer sk-tts-your-key" \
-F "file=@noisy_audio.mp3" \
-F "denoise=true" \
-F "enhance_clarity=true" \
-o enhanced.mp3
Error Codes
All errors return a JSON response with an error field.
{
"error": {
"code": "insufficient_credits",
"message": "You do not have enough characters for this request.",
"characters_required": 4000,
"characters_available": 2000
}
}
| HTTP Status | Error Code | Description |
|---|---|---|
| 400 | bad_request |
Invalid request parameters. Check the error message for details. |
| 401 | unauthorized |
Missing or invalid API key. |
| 402 | insufficient_credits |
Not enough characters. Purchase more at /pricing/. |
| 403 | forbidden |
API access not available on your plan. |
| 404 | not_found |
Model or voice not found. |
| 413 | file_too_large |
Uploaded file exceeds the size limit. |
| 429 | rate_limited |
Too many requests. Check rate limit headers. |
| 500 | internal_error |
Server error. Try again later. |
| 503 | model_loading |
Model is loading. Retry in a few seconds. |
Webhooks
For long-running tasks (stem splitting, batch TTS), you can provide a webhook_url parameter. When the task completes, we will POST the result to your URL.
{
"event": "task.completed",
"task_id": "task_abc123",
"status": "success",
"result_url": "https://api.tts.ai/v1/results/task_abc123",
"credits_used": 12,
"created_at": "2025-01-15T10:30:00Z",
"completed_at": "2025-01-15T10:30:45Z"
}
Ready to Build?
Get your API key and start integrating TTS.ai into your applications.