Skip to main content

Text to Speech

Turn text into natural speech with a project-scoped API key.

When to use it

Voiceovers and narrationProduct demos, videos, stories, and long-form content.
Conversational experiencesTurn an assistant response into audio or stream it as it is generated.
Accessibility and IVRRead content aloud, build phone menus, and create spoken guidance.
Product notificationsGenerate alerts, status updates, and personalized messages.

Quick start

Set the API address and key before running an example. See Get your API key if you do not have one yet.

export VUILABS_API_BASE_URL="https://api-global.vuilabs.ai"
export VUILABS_API_KEY="your-api-key"
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": "Your order is ready.",
"language": "en",
"speed": 1
}' \
--output speech.mp3

Use a specific voice

Set voice_id to a voice enabled for your project. Start with a short representative sentence before generating longer content.

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": "This request uses a specific voice.",
"voice_id": "your-approved-voice-id",
"language": "en",
"speed": 1
}' \
--output speech.mp3

API details

Request modes

COMPLETE AUDIOPOST /v1/text-to-speech

Wait for the complete audio response before playback or storage.

STREAMING AUDIOPOST /v1/text-to-speech/stream

Consume raw audio bytes as they become available.

Both endpoints use X-API-Key. The key determines the project, allowed capability, rate limit, and billing account.

Request headers

HeaderRequiredDescription
X-API-KeyYesYour project API key.
Content-TypeYesapplication/json

JSON body

FieldTypeRequiredUse it for
generate_textstringYesThe text to synthesize. Billing uses weighted character count.
languagestringNoA language enabled for your TTS account.
voice_idstringNoAn approved voice. Omit to use the configured default voice.
speednumberNoDelivery speed. Omit or use 0 for the provider default; negative values are rejected.
emotion_classstringNoAn approved emotion preset, when supported by the selected voice.
audio_formatstringNoAn output format enabled for the selected voice and request mode.

Streaming generation

The synchronous endpoint returns the complete file. The streaming endpoint returns HTTP chunked raw audio bytes in order; it is not SSE or a JSON event stream.

Handle the response as audio

For both endpoints, HTTP 200 means the response body is audio, not JSON. The response Content-Type is the actual audio MIME type returned by the approved provider.