Text to Speech

Convert text to raw audio bytes with POST /v1/tts or stream synthesis directly over wss://api.x.ai/v1/tts. xAI's TTS surface uses five built-in voices, BCP-47 language codes, speech tags, and an object-shaped output_format.

CLI

progrok tts "Hello, welcome to progrok."   --voice eve --language en --format mp3 --output speech.mp3

Use --stdout for raw bytes or --json for result metadata; --stdout cannot be combined with --output or --json.

REST

curl -X POST http://localhost:18645/v1/tts   -H "Authorization: Bearer $API_KEY"   -H "Content-Type: application/json"   -d '{
    "voice_id": "eve",
    "text": "Hello, welcome to progrok.",
    "language": "en",
    "output_format": {"codec": "mp3", "sample_rate": 44100, "bit_rate": 192000},
    "speed": 1.0
  }' --output speech.mp3
ParameterTypeDescription
textstringRequired. 1-60,000 characters in the progrok client. Supports inline tags like [pause] and wrapping tags like <whisper>.
voice_idstringBuilt-ins: ara, eve, leo, rex, sal. Custom voice IDs are also accepted.
languagestringRequired BCP-47 code such as en, ko, pt-BR, or auto.
output_formatobject{codec: "mp3"|"wav"|"pcm"|"mulaw"|"alaw", sample_rate, bit_rate}. MP3 defaults to 24 kHz / 128 kbps.
speednumberPlayback speed multiplier, range 0.7-1.5.
optimize_streaming_latencystring"0" or "1". Lower first-audio latency trades off chunk quality.
text_normalizationbooleanNormalize written-form text before synthesis.

alloy, opus, flac, and OpenAI-style 0.25-4.0 speed ranges are not xAI TTS values.

Streaming WebSocket

The typed client connects directly to wss://api.x.ai/v1/tts with a server-side bearer, sends text.delta and text.done, and yields JSON audio.delta/audio.done events. Browser ephemeral authentication has not been verified for TTS.