xAI Text-to-Speech
xAI Text-to-Speech converts text into natural-sounding spoken audio with a single API call. It offers five expressive voices (Eve, Ara, Leo, Rex, and Sal), inline speech tags for fine-grained control over pauses, laughter, whispers, and emphasis, and supports over 20 auto-detected languages.
API Options
Platform-level options for task execution and delivery.
-
taskType
string required value: audioInference -
Identifier for the type of task being performed
-
taskUUID
string required UUID v4 -
UUID v4 identifier for tracking tasks and matching async responses. Must be unique per task.
-
outputType
string default: URL -
Audio output type.
Allowed values 3 values
-
outputFormat
string default: MP3 -
Specifies the file format of the generated output. The available values depend on the task type and the specific model's capabilities.
- `MP3`: Compressed audio, smaller file size.
- `WAV`: Uncompressed, high-quality audio.
- `FLAC`: Lossless compression.
- `OGG`: Open-source compressed audio format (Vorbis codec).
Allowed values 4 values
-
audioSettings
object -
Audio encoding settings for controlling the bitrate, number of channels, and sample rate of the generated audio. Only applicable for lossy output formats (
MP3andOGG). When using lossless formats (WAVorFLAC), this parameter must not be provided.The available sample rates and valid bitrate ranges depend on the output format. For
OGG, bitrate limits also vary by the number of channels.MP3 bitrate limits
Bitrate limits for MP3 are the same regardless of mono or stereo.
Sample Rate Min Bitrate Max Bitrate 8,000 Hz 8 kbps 64 kbps 11,025 Hz 8 kbps 64 kbps 12,000 Hz 8 kbps 64 kbps 16,000 Hz 8 kbps 160 kbps 22,050 Hz 8 kbps 160 kbps 24,000 Hz 8 kbps 160 kbps 32,000 Hz 32 kbps 320 kbps 44,100 Hz 32 kbps 320 kbps 48,000 Hz 32 kbps 320 kbps OGG bitrate limits — Mono (1 channel)
Sample Rate Min Bitrate Max Bitrate 8,000 Hz 8 kbps 40 kbps 12,000 Hz 16 kbps 48 kbps 16,000 Hz 16 kbps 96 kbps 24,000 Hz 16 kbps 80 kbps 48,000 Hz 32 kbps 224 kbps OGG bitrate limits — Stereo (2 channels)
Sample Rate Min Bitrate Max Bitrate 8,000 Hz 16 kbps 80 kbps 12,000 Hz 16 kbps 96 kbps 16,000 Hz 24 kbps 192 kbps 24,000 Hz 32 kbps 160 kbps 48,000 Hz 48 kbps 256 kbps Lossless formats: When
outputFormatis set toWAVorFLAC, theaudioSettingsparameter is not available since these formats produce uncompressed or lossless audio with no configurable encoding settings.Properties 3 properties
-
audioSettings»bitratebitrate
integer min: 8 -
Audio bitrate in kbps.
-
audioSettings»channelschannels
integer default: 2 -
Number of audio channels. 1 for mono, 2 for stereo.
Allowed values 2 values
-
audioSettings»sampleRatesampleRate
integer -
Audio sample rate in Hz.
-
-
webhookURL
string URI -
Specifies a webhook URL where JSON responses will be sent via HTTP POST when generation tasks complete. For batch requests with multiple results, each completed item triggers a separate webhook call as it becomes available.
Learn more 1 resource
- Webhooks PLATFORM
- Webhooks
-
deliveryMethod
string default: sync -
Determines how the API delivers task results.
Allowed values 2 values
- Returns complete results directly in the API response.
- Returns an immediate acknowledgment with the task UUID. Poll for results using getResponse.
Learn more 1 resource
- Task Polling PLATFORM
-
uploadEndpoint
string URI -
Specifies a URL where the generated content will be automatically uploaded using the HTTP PUT method. The raw binary data of the media file is sent directly as the request body. For secure uploads to cloud storage, use presigned URLs that include temporary authentication credentials.
Common use cases:
- Cloud storage: Upload directly to S3 buckets, Google Cloud Storage, or Azure Blob Storage using presigned URLs.
- CDN integration: Upload to content delivery networks for immediate distribution.
// S3 presigned URL for secure upload https://your-bucket.s3.amazonaws.com/generated/content.mp4?X-Amz-Signature=abc123&X-Amz-Expires=3600 // Google Cloud Storage presigned URL https://storage.googleapis.com/your-bucket/content.jpg?X-Goog-Signature=xyz789 // Custom storage endpoint https://storage.example.com/uploads/generated-image.jpgThe content data will be sent as the request body to the specified URL when generation is complete.
-
ttl
integer min: 60 -
Time-to-live (TTL) in seconds for generated content. Only applies when
outputTypeisURL.
-
includeCost
boolean default: false -
Include task cost in the response.
-
numberResults
integer min: 1 max: 4 default: 1 -
Number of results to generate. Each result uses a different seed, producing variations of the same parameters.
Generation Parameters
Core parameters for controlling the generated content.
-
model
string required value: xai:tts@0 -
Identifier of the model to use for generation.
Learn more 3 resources
-
speech
object required -
Settings for speech generation.
Properties 3 properties
-
speech»texttext
string required -
Text to convert to speech.
-
speech»voicevoice
string required default: auto -
Voice identifier to use. Set to
autofor automatic selection.Allowed values 6 values
-
speech»languagelanguage
string min: 1 -
Language code for speech generation.
Allowed values 20 values
-
French Travel Narration
{
"taskType": "audioInference",
"taskUUID": "583bb6a1-3d00-484f-a442-f1e61bf53dd7",
"model": "xai:tts@0",
"speech": {
"text": "Bienvenue à Paris. <pause time=\"700ms\"/> Au lever du soleil, la Seine scintille comme un ruban d'or, les cafés s'éveillent lentement, et la ville murmure déjà ses histoires. <emphasis level=\"strong\">Écoutez</emphasis> le tintement des tasses, le pas pressé des passants, et le souffle léger du vent autour de la tour Eiffel. <pause time=\"500ms\"/> Ce voyage commence ici, avec élégance, lumière, et un peu de magie.",
"voice": "eve",
"language": "fr"
}
}{
"taskType": "audioInference",
"taskUUID": "583bb6a1-3d00-484f-a442-f1e61bf53dd7",
"audioUUID": "43b5f1e3-5853-42f9-9b34-a74c502f0001",
"audioURL": "https://am.runware.ai/audio/os/a18d05/ws/5/ai/43b5f1e3-5853-42f9-9b34-a74c502f0001.mp3",
"cost": 0.00174
}Expressive Story Narration
{
"taskType": "audioInference",
"taskUUID": "e844d206-9c52-4597-bc4a-f83313956968",
"model": "xai:tts@0",
"speech": {
"text": "The observatory lights dimmed one by one. [pause] Above the mountain, the sky opened like black velvet stitched with stars. \"Do you see it?\" she whispered. [whisper] \"The comet is early.\" [pause] Then, with a sudden laugh, she pointed east. [laugh] \"There! A silver flame across the dark.\" And for one breathless moment, the whole world stood still.",
"voice": "eve",
"language": "en"
}
}{
"taskType": "audioInference",
"taskUUID": "e844d206-9c52-4597-bc4a-f83313956968",
"audioUUID": "21467765-7783-4630-8c0d-e618dca19eb7",
"audioURL": "https://am.runware.ai/audio/os/a01d21/ws/5/ai/21467765-7783-4630-8c0d-e618dca19eb7.mp3",
"cost": 0.00147
}Spanish Travel Narration
{
"taskType": "audioInference",
"taskUUID": "3cc30108-1696-446e-9d02-3c77a94183ef",
"model": "xai:tts@0",
"speech": {
"text": "Bienvenidos a Sevilla, una ciudad de luz dorada, patios llenos de flores y música que vibra en cada rincón. Al caer la tarde, la Giralda se recorta contra el cielo, y las calles estrechas invitan a perderse sin prisa. [pause] Respira hondo. Escucha el murmullo de las plazas, el eco de los pasos sobre la piedra y la calidez de una noche que apenas comienza.",
"voice": "eve",
"language": "es-ES"
}
}{
"taskType": "audioInference",
"taskUUID": "3cc30108-1696-446e-9d02-3c77a94183ef",
"audioUUID": "2457d5b1-ee39-4d7a-af4d-aab1cee49ed6",
"audioURL": "https://am.runware.ai/audio/os/a10d08/ws/5/ai/2457d5b1-ee39-4d7a-af4d-aab1cee49ed6.mp3",
"cost": 0.0015
}Hindi Guided Meditation
{
"taskType": "audioInference",
"taskUUID": "4a9f110c-7e7a-4f76-91f5-f5e9648d85af",
"model": "xai:tts@0",
"speech": {
"text": "अपनी आँखें धीरे से बंद करें, और एक लंबी, गहरी साँस लें। <pause time=\"1.5s\"/> महसूस करें कि हर साँस के साथ आपका मन शांत होता जा रहा है। <pause time=\"1s\"/> आपके आसपास एक कोमल, सुनहरी रोशनी फैल रही है, जो आपको सुरक्षा, स्थिरता और सुकून का एहसास दे रही है। <pause time=\"1.5s\"/> अब धीरे-धीरे साँस छोड़ें, और दिन भर का तनाव अपने शरीर से बाहर जाने दें।",
"voice": "ara",
"language": "hi"
}
}{
"taskType": "audioInference",
"taskUUID": "4a9f110c-7e7a-4f76-91f5-f5e9648d85af",
"audioUUID": "dcbcc15a-5273-4c3a-b87c-569f95adf918",
"audioURL": "https://am.runware.ai/audio/os/a19d05/ws/5/ai/dcbcc15a-5273-4c3a-b87c-569f95adf918.mp3",
"cost": 0.00145
}