API Documentation
Integrate DubVoice.ai text-to-speech capabilities into your applications with our REST API.
Quick Start
Get started with a simple API request:
curl -X POST "https://dubvoice.ai/api/v1/tts" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, welcome to DubVoice!",
"voice_id": "sarah",
"language": "en"
}'Authentication
All API requests require authentication using an API key. You can obtain your API key from your dashboard.
Important: Keep your API key secure. Never expose it in client-side code or public repositories.
Include your API key in the request header:
Authorization: Bearer YOUR_API_KEY
API Endpoints
/api/v1/ttsConvert text to speech audio.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The text to convert to speech (max 5000 characters) |
voice_id | string | Yes | The ID of the voice to use |
language | string | No | Language code (e.g., "en", "es", "tr") |
speed | number | No | Speech speed (0.5 - 2.0, default: 1.0) |
format | string | No | Output format: "mp3" or "wav" (default: "mp3") |
Response
Returns audio file as binary stream with appropriate Content-Type header.
HTTP/1.1 200 OK Content-Type: audio/mpeg Content-Disposition: attachment; filename="tts_output.mp3" [Binary audio data]
/api/v1/voicesGet a list of available voices.
Response
{
"voices": [
{
"id": "sarah",
"name": "Sarah",
"language": "en",
"gender": "female",
"preview_url": "https://dubvoice.ai/samples/sarah.mp3"
},
{
"id": "james",
"name": "James",
"language": "en",
"gender": "male",
"preview_url": "https://dubvoice.ai/samples/james.mp3"
}
]
}/api/v1/userGet current user information and credit balance.
Response
{
"user": {
"id": "usr_123456",
"email": "user@example.com",
"credits": 50000,
"plan": "pro"
}
}Supported Languages
enEnglish
esSpanish
frFrench
deGerman
itItalian
ptPortuguese
trTurkish
ruRussian
jaJapanese
koKorean
zhChinese
arArabic
hiHindi
plPolish
nlDutch
svSwedish
And 15+ more languages available. Check the voices endpoint for full list.
Error Codes
| Code | Status | Description |
|---|---|---|
400 | Bad Request | Invalid request parameters |
401 | Unauthorized | Invalid or missing API key |
402 | Payment Required | Insufficient credits |
429 | Too Many Requests | Rate limit exceeded |
500 | Server Error | Internal server error |
Code Examples
JavaScript / Node.js
const response = await fetch('https://dubvoice.ai/api/v1/tts', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: 'Hello, welcome to DubVoice!',
voice_id: 'sarah',
language: 'en',
}),
});
const audioBlob = await response.blob();
const audioUrl = URL.createObjectURL(audioBlob);
const audio = new Audio(audioUrl);
audio.play();Python
import requests
response = requests.post(
'https://dubvoice.ai/api/v1/tts',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={
'text': 'Hello, welcome to DubVoice!',
'voice_id': 'sarah',
'language': 'en',
}
)
with open('output.mp3', 'wb') as f:
f.write(response.content)cURL
curl -X POST "https://dubvoice.ai/api/v1/tts" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hello, welcome to DubVoice!", "voice_id": "sarah", "language": "en"}' \
--output output.mp3Rate Limits
| Plan | Requests/min | Concurrent Requests |
|---|---|---|
| Free | 10 | 2 |
| Pro | 60 | 5 |
| Enterprise | Unlimited | Custom |
Ready to Get Started?
Create a free account to get your API key and start building with DubVoice.ai.