Generate speech in 5 minutes
Before you start
Create a project and an API key before making a request. See Get your API key for the complete steps.
export VUILABS_API_BASE_URL="https://api.vuilabs.ai"
export VUILABS_API_KEY="your-api-key"
Before running the request, replace YOUR_PROJECT_VOICE_ID with a voice available to this API key. It is not a shared demo voice; for a cloned voice, create it first with the Voice Cloning API.
Never share your API key or add it to public source code.
Generate your first audio
- cURL
- JavaScript
- Python
curl --request POST \
--url "$VUILABS_API_BASE_URL/v1/text-to-speech" \
--header "X-API-Key: $VUILABS_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"text": "Hello from VUILabs.",
"voice_id": "YOUR_PROJECT_VOICE_ID",
"language": "en",
"speed": 1
}' \
--output speech.wav
import { writeFile } from 'node:fs/promises';
const response = await fetch(`${process.env.VUILABS_API_BASE_URL}/v1/text-to-speech`, {
method: 'POST',
headers: {
'X-API-Key': process.env.VUILABS_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
text: 'Hello from VUILabs.',
voice_id: 'YOUR_PROJECT_VOICE_ID',
language: 'en',
speed: 1,
}),
});
if (!response.ok) throw new Error(await response.text());
await writeFile('speech.wav', Buffer.from(await response.arrayBuffer()));
import os
import requests
response = requests.post(
f"{os.environ['VUILABS_API_BASE_URL']}/v1/text-to-speech",
headers={"X-API-Key": os.environ["VUILABS_API_KEY"]},
json={"text": "Hello from VUILabs.", "voice_id": "YOUR_PROJECT_VOICE_ID", "language": "en", "speed": 1},
)
response.raise_for_status()
with open("speech.wav", "wb") as output:
output.write(response.content)
What happens next
The API returns raw audio bytes in an HTTP 200 response. Save the response to a file or pass it directly to an audio player.
Need to specify a voice? Choose a voice_id enabled for the current project.
Need the first audio chunk sooner? Switch to the streaming endpoint.
✓Need a different audio format? Both complete and Luna-TTS streaming requests support WAV (default) or raw PCM. Send audio_format: "pcm" for PCM and read the response audio metadata before playback.
Continue to Voices and output, or see the full Text to Speech API reference.