Generate speech in 5 minutes
Send text to the Text-to-Speech endpoint and receive an audio file. This guide uses a synchronous request; see streaming generation when you need audio chunks as soon as they are available.
Before you start
Create a project and API key before making a request. See Get your API key for the complete walkthrough.
export VUILABS_API_BASE_URL="https://api-global.vuilabs.ai"
export VUILABS_API_KEY="your-api-key"
Keep your key safe
Never share your API key or add it to public source code.
Make your first request
- 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 '{
"generate_text": "Hello from VUILabs.",
"language": "en",
"speed": 1
}' \
--output speech.mp3
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({
generate_text: 'Hello from VUILabs.',
language: 'en',
speed: 1,
}),
});
if (!response.ok) throw new Error(await response.text());
await writeFile('speech.mp3', 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={"generate_text": "Hello from VUILabs.", "language": "en", "speed": 1},
)
response.raise_for_status()
with open("speech.mp3", "wb") as output:
output.write(response.content)
What happens next
The API returns raw audio bytes with HTTP 200. Save the response to a file or pass it directly to your audio player.
✓
Need another voice? Choose an approved voice_id.
Need a faster first sound? Switch to the streaming endpoint.
✓Need a different file type? Set audio_format when it is enabled for your voice.
Continue with voices and output options, or open the full Text-to-Speech API reference.