xAI TTS 1 Text to Speech API
xai/tts/v1xAI TTS 1 Text to Speech turns scripts into multilingual audio with five voices and expressive speech tags. Place pauses and laughter within a line, or wrap a passage in tags to guide whispers and slower delivery.
xAI TTS 1 Text to Speech API
Generate speech with the API
Submit a script, keep the returned task_id, and retrieve the completed audio through the task status endpoint.
Authenticate your request
Send your Vidgo API key in the Authorization header using Bearer authentication.
- Endpoint
- POST
https://api.vidgo.ai/api/generate/submit - Authentication
- Authorization: Bearer YOUR_API_KEY
Submit the script
Send model and input as JSON. The example combines pauses and whispered speech.
REQUEST_BODY=$(cat <<'JSON'
{
"model": "xai/tts/v1",
"input": {
"text": "Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.",
"voice": "eve",
"language_code": "auto",
"output_format": {
"codec": "mp3",
"sample_rate": 24000,
"bit_rate": 128000
}
}
}
JSON
)
RESPONSE=$(curl --silent --show-error --fail-with-body \
--request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data "$REQUEST_BODY")
CODE=$(printf '%s' "$RESPONSE" | jq -r '.code // empty')
if [ "$CODE" != "0" ] && [ "$CODE" != "200" ]; then
printf 'API error: %s
' "$RESPONSE" >&2
exit 1
fi
printf '%s
' "$RESPONSE"Follow the task
Query the returned task_id until status is finished or failed.
Status endpoint
GET https://api.vidgo.ai/api/generate/status/{task_id}Keep the task_id from submission. Check its status and read the generated files when it finishes.
not_startedrunningfinishedfailed{
"code": 200,
"data": {
"task_id": "your_task_id",
"status": "not_started",
"created_time": "2026-09-27T10:00:00"
}
}{
"code": 200,
"data": {
"task_id": "your_task_id",
"status": "finished",
"files": [
{
"file_url": "https://example.com/generated-speech.mp3",
"file_type": "audio",
"file_name": "speech.mp3"
}
],
"error_message": null,
"progress": 100
}
}Read the audio files
Read files with file_type set to audio, then use file_url to download the speech.
set -euo pipefail
: "${VIDGO_API_KEY:?Set VIDGO_API_KEY in your environment}"
REQUEST_BODY=$(cat <<'JSON'
{
"model": "xai/tts/v1",
"input": {
"text": "Welcome to our story. [pause] <whisper>Listen closely.</whisper> [laugh] Let us begin.",
"voice": "eve",
"language_code": "auto",
"output_format": {
"codec": "mp3",
"sample_rate": 24000,
"bit_rate": 128000
}
}
}
JSON
)
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
--request POST \
--url "https://api.vidgo.ai/api/generate/submit" \
--header "Authorization: Bearer $VIDGO_API_KEY" \
--header "Content-Type: application/json" \
--data "$REQUEST_BODY")
TASK_ID=$(printf '%s' "$SUBMIT_RESPONSE" | jq -r '.data.task_id // .task_id // empty')
BUSINESS_CODE=$(printf '%s' "$SUBMIT_RESPONSE" | jq -r '.code // empty')
if [ "$BUSINESS_CODE" != "0" ] && [ "$BUSINESS_CODE" != "200" ]; then
printf 'Submit failed:
%s
' "$SUBMIT_RESPONSE" >&2
exit 1
fi
if [ -z "$TASK_ID" ]; then
printf 'Submit response did not include task_id:
%s
' "$SUBMIT_RESPONSE" >&2
exit 1
fi
START_TIME=$(date +%s)
POLL_DELAY=2
while true; do
if [ $(( $(date +%s) - START_TIME )) -ge 600 ]; then
printf 'Timed out after 600 seconds
' >&2
exit 1
fi
STATUS_RESPONSE=$(curl --silent --show-error --fail-with-body \
--url "https://api.vidgo.ai/api/generate/status/$TASK_ID" \
--header "Authorization: Bearer $VIDGO_API_KEY")
STATUS=$(printf '%s' "$STATUS_RESPONSE" | jq -r '.data.status // .status // empty')
BUSINESS_CODE=$(printf '%s' "$STATUS_RESPONSE" | jq -r '.code // empty')
if [ "$BUSINESS_CODE" != "0" ] && [ "$BUSINESS_CODE" != "200" ]; then
printf 'Status request failed:
%s
' "$STATUS_RESPONSE" >&2
exit 1
fi
case "$STATUS" in
finished)
printf '%s' "$STATUS_RESPONSE" | jq -r '(.data.files // .files // [])[]?.file_url'
break
;;
failed)
printf '%s' "$STATUS_RESPONSE" | jq -r '.data.error_message // .error_message // "Generation failed"' >&2
exit 1
;;
not_started|running)
sleep "$POLL_DELAY"
if [ "$POLL_DELAY" -lt 10 ]; then POLL_DELAY=$((POLL_DELAY + 1)); fi
;;
*)
printf 'Unexpected task status: %s
' "$STATUS" >&2
exit 1
;;
esac
doneRequest parameters
Place speech controls inside input; keep model and callback_url at the top level.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | — | Set model to xai/tts/v1. |
| input | object | Yes | — | Contains the script and speech controls listed below. |
| input.text | string | Yes | — | Text to speak, from 1 to 15,000 characters after trimming leading and trailing whitespace. Use [laugh], [pause], [sigh], <whisper>text</whisper>, or <slow>text</slow> to direct delivery. |
| input.voice | string | No | eve | Choose eve, ara, rex, sal, or leo for your narrator or character. Default: eve. |
| input.language_code | string | No | auto | Choose a listed BCP-47 language code, or auto for automatic language detection. auto, en, ar-EG, ar-SA, ar-AE, bn, zh, fr, de, hi, id, it, ja, ko, pt-BR, pt-PT, ru, es-MX, es-ES, tr, vi |
| input.output_format | object | No | — | An object containing codec, sample_rate, and the MP3 bit_rate setting. |
| input.output_format.codec | string | No | mp3 | Audio encoding: mp3, wav, pcm, mulaw, or alaw. Default: mp3. |
| input.output_format.sample_rate | integer | No | 24000 | Sample rate in Hz: 8000, 16000, 22050, 24000, 44100, or 48000. Default: 24000. |
| input.output_format.bit_rate | integer | null | No | 128000 (mp3) | MP3 bitrate in bits per second: 32000, 64000, 96000, 128000, 192000, or null. MP3 default: 128000. For wav, pcm, mulaw, and alaw, omit bit_rate or set it to null. |
| callback_url | string | No | — | Optional HTTP or HTTPS URL for task notifications. Include it at the top level of the request. |
Response fields
Submission identifies the task. Status responses report progress toward the completed audio.
| Field | Type | Description |
|---|---|---|
| code | integer | Response code. A successful response uses 200 or 0. |
| data.task_id | string | Task identifier used to query status. |
| data.status | string | Task state: not_started, running, finished, or failed. |
| data.created_time | string | Task creation time returned by the service. |
| data.files | array | Generated speech files. |
| data.files[].file_url | string | URL used to play or download a generated file. |
| data.files[].file_type | string | Generated speech uses audio. |
| data.files[].file_name | string | File name, when returned. |
| data.error_message | string | null | Error details when a task fails. |
Task lifecycle
Use the task state to decide when to check again or read the result.
not_startedThe task has been accepted and is waiting to start.
runningSpeech generation is in progress. Continue checking the same task.
finishedGeneration is complete. Read files to retrieve the speech.
failedGeneration failed. Read error_message before deciding whether to submit a new request.
Handle results and interruptions
- Keep the current task identifierIf a status request is interrupted, query the same task_id again to recover its latest state.
- Read the audio resultUse the file_url and file_name from each audio entry to download the speech.
- Inspect a failed taskWhen status is failed, read error_message and review the script and settings before submitting another generation.
Speech specifications
| Item | Value | Description |
|---|---|---|
| Task | Text to Speech | Generate speech from text and a selected voice. |
| Text length | 1–15,000 | Unicode characters after trimming leading and trailing whitespace. |
| Voices | eve, ara, rex, sal, leo | Select the preset through input.voice. |
| Languages | auto, en, ar-EG, ar-SA, ar-AE, bn, zh, fr, de, hi, id, it, ja, ko, pt-BR, pt-PT, ru, es-MX, es-ES, tr, vi | Choose a language code or auto. |
| Output | mp3, wav, pcm, mulaw, alaw | Configure the encoding and sample rate in output_format. |
xAI TTS 1 Text to Speech API frequently asked questions
What is the xAI TTS 1 Text to Speech API?
xAI TTS 1 Text to Speech is an xAI model that turns scripts into narration and character lines. It offers five voices, multilingual speech and expressive text tags for stories and lessons. Inline tags direct local pauses and vocal expressions, while wrapping tags guide whispers or slower delivery across a passage. You can call it programmatically or try it in the Playground tab.
Which voices can I choose in xAI TTS 1?
Voice offers eve, ara, rex, sal and leo, with eve as the default. Compare them using the same lines before choosing a voice for narration or a character.
How do inline speech tags work in xAI TTS 1?
Add [pause], [laugh] or [sigh] in Text where you want a pause, laugh or sigh. Keep tags next to the relevant words so you can review and refine delivery line by line.
How do wrapping tags work in xAI TTS 1?
Use <whisper>words</whisper> to guide whispers and <slow>words</slow> for slower delivery. Paired tags enclose the text you want to direct, allowing different passages within one script to use different delivery styles.
How do I choose a language in xAI TTS 1?
Set Language Code to auto for automatic detection, or select a code such as zh, en or ja. Portuguese, Spanish and Arabic have regional options in the list; choose the code that matches the script.
How long can an xAI TTS 1 script be?
Each request accepts 1–15,000 Unicode characters after trimming leading and trailing whitespace. Tags, punctuation and internal spaces count toward the limit. Split longer work into passages using the same voice, language and output settings.
Which audio formats does xAI TTS 1 offer?
Output Format.Codec offers mp3, wav, pcm, mulaw and alaw. Preview MP3 and WAV on the page, or download PCM, mulaw and alaw for audio systems. Choose a sample rate from the options listed in Parameters.
How do I set the MP3 bitrate in xAI TTS 1?
For mp3, choose 32000, 64000, 96000, 128000 or 192000 in Output Format.Bit Rate, measured in bit/s; the default is 128000. With other codecs, omit bit_rate or set it to null and configure the codec and sample rate.