In short.
This xAI guide explains speech generation for developers building audio features, but does not establish pricing, usage rights or measured performance. It documents complete-text HTTP requests and persistent WebSocket sessions, including pronunciation replacements, character timings and cancellation. The integration details support practical planning; sound quality, language accuracy, latency and reliability remain unassessed.
Researched and written by an AI model and checked by a second AI model. How it works
The scope is the complete documentation page at [https://docs.x.ai/developers/model-capabilities/audio/text-to-speech.md], including examples, limits, browser notes, pronunciation controls and WebSocket behavior. Linked pages, console interfaces and audio demos are excluded. Empty speech-tag tables limit the available tag inventory. Pricing and usage terms are absent, and no documented behavior was executed or independently measured.
The overview
Resource identity
The resource is the text-to-speech documentation at [https://docs.x.ai/developers/model-capabilities/audio/text-to-speech.md]. It explains a hosted speech-generation service through HTTP and WebSocket interfaces, with examples in curl, Python, JavaScript and Swift.
The page identifies service endpoints and request parameters but gives no underlying synthesis-model name or version. It is an integration guide rather than a downloadable model or code library.
Practical assessment
The guide is useful for planning narration, browser playback, telephony audio and spoken responses to incrementally generated text. Its strongest details concern integration boundaries: response formats, pronunciation matching, timing metadata and interruption handling.
Suitability depends on the intended voice, language, latency needs and commercial terms. The page supplies no measured quality comparisons, service reliability figures or latency benchmarks. Its streaming options explicitly trade audio quality at chunk boundaries for faster initial audio.
Who it helps
Beginners with basic HTTP knowledge can follow the examples to request an audio file. Experienced developers get protocol details for persistent connections, cancellation, timing metadata and pronunciation dictionaries.
Potential applications include article narration, spoken notifications, caption highlighting and telephone prompts. These are uses supported by the documented interfaces, not demonstrated production deployments. Complete voice conversations and custom-voice creation are covered by linked resources whose contents are outside this page.
Documented capabilities
The page lists 20 language and regional codes, plus automatic language detection, and says every built-in voice supports every listed language. Examples use eve, ara and rex; the complete voice inventory is available through a separate endpoint. Custom voice IDs are also accepted.
Delivery controls include inline pauses and laughter, wrapping styles such as whispering, and a speed multiplier from 0.7 to 1.5. Optional text normalization expands written forms such as numbers into spoken forms. Pronunciation replacements accept respellings or International Phonetic Alphabet symbols.
Output codecs are MP3, WAV, PCM, μ-law and A-law. Listed sample rates range from 8,000 to 48,000 Hz; MP3 bitrates range from 32,000 to 192,000 bits per second. Optional character timings support synchronized text displays, although their accuracy is unassessed.
Using it
Access and dependencies
The examples require an xAI API key, network access and an HTTP or WebSocket client. Authentication uses a bearer token. The documented browser architecture routes requests through a backend so the key remains server-side.
Basic HTTP examples do not require a vendor SDK. The Python examples use requests, while Python streaming examples use websockets; JavaScript streaming examples import ws. Required package versions, account eligibility, billing prerequisites and ordinary request-rate quotas are not specified.
How the interfaces work
HTTP requests send JSON to [https://api.x.ai/v1/tts]. Text and language are required; voice defaults to eve. The normal response contains audio bytes, with MP3 at 24 kHz and 128 kbps as the default. Enabling with_timestamps changes the response to JSON containing base64-encoded audio, duration and character timing arrays, and adds a post-synthesis alignment pass.
WebSocket connections use [wss://api.x.ai/v1/tts]. Clients send text.delta messages and finish each utterance with text.done. The server returns base64 audio.delta messages and audio.done. The connection supports subsequent utterances; text.clear cancels the current one and produces audio.clear.
Pronunciation maps are applied before synthesis. Over WebSockets, session.update sets a map that persists across utterances and cancellation. Each utterance uses the map active when its first text arrived, and phrase matching spans text.delta boundaries.
Getting started
The documented setup is to obtain an API key, keep it on the backend, choose a language and submit a short request. Available built-in voices can be retrieved from [https://api.x.ai/v1/tts/voices]. MP3 or WAV fits the browser playback examples; raw PCM and telephony codecs require a suitable playback or processing pipeline.
Error handling should distinguish invalid requests and credentials from retryable failures. The page recommends exponential backoff for HTTP 429, 500 and 503. Browser integration also needs audio-resource cleanup and attention to Safari playback behavior; cross-browser compatibility has not been assessed.
Example request
A documented minimal request posts {"text":"Hello world.","voice_id":"eve","language":"en"} to [https://api.x.ai/v1/tts], using bearer authentication and the application/json request content type. Without additional options, the documented response is MP3 audio that can be saved directly.
Adding "with_timestamps":true changes the response handling: decode the audio field from base64, then read matching entries in audio_timestamps.graph_chars and graph_times. Replacements make those characters follow the spoken replacement text, while normalization can assign several spoken words to one written token. Highlighting therefore needs to follow the returned alignment rather than assume a direct mapping to the original text.
Assessment & evidence
Limits and unresolved details
HTTP requests have a documented 60,000-character input cap and 15-minute timeout. WebSockets have no stated total session text cap, but each text.delta is limited to 60,000 characters and concurrency is limited to 50 sessions per team. The page lists both no connection timeout and a 600-second session permit TTL without explaining their relationship.
Replacement maps allow 200 entries, keys up to 100 characters and values up to 128 characters. Keys allow letters, digits, apostrophes and spaces; other punctuation and symbols, including the plus signs in C++, are rejected. HTTP replacement expansion is capped at 240,000 characters; exceeding that size for a WebSocket utterance ends the session.
The captured speech-tag tables contain empty tag cells, so they do not provide a complete tag inventory. Additional, unlisted languages have unspecified accuracy. WebSocket moderation is described as asynchronous and occurring after audio is sent, so it does not establish screening before audio delivery.
How to judge the fit
The documented interfaces suggest HTTP as a straightforward starting point when the full text is already available. WebSockets offer useful controls when text arrives incrementally or playback needs interruption, with additional responsibility for connection state, decoding and audio queues.
Pronunciation replacements and character timings are particularly relevant to technical narration and synchronized displays. Their usefulness depends on actual pronunciation and alignment quality, which the page does not demonstrate. Sample-rate labels and configurable latency levels alone do not establish the listening experience.
Other routes to consider
Within this service, HTTP and WebSockets address different integration needs. The linked console playground provides a browser route for exploring voices and settings, while the linked speech-to-speech API addresses voice conversations. Those linked resources are not independently described by the supplied evidence.
The page contains no comparative evidence about competing speech APIs or locally hosted speech models. Relative quality, cost, privacy and deployment tradeoffs therefore remain unassessed.
Evidence and confidence
The evidence is the complete first-party documentation page at [https://docs.x.ai/developers/model-capabilities/audio/text-to-speech.md]. It supports descriptions of parameters, response shapes, protocol events and stated limits.
Code and response examples are illustrative, with no observed execution results supplied. Nothing was run. Audio quality, pronunciation consistency, timestamp accuracy, browser compatibility, latency and service reliability are not assessed. Linked demos, console pages and reference documents provide no additional evidence here.
Access & freshness
Pricing and billing
API prices are unknown: the page supplies no currency, character rate, subscription price or free-credit allowance. It states that WebSocket billing is recorded per session using total input characters, and pronunciation replacements are billed against the original submitted text rather than the expanded spoken text.
The page says custom voices can be created free in the console. That statement does not establish free speech synthesis or other custom-voice charges. The financial treatment of cancelled utterances and repeated requests is unspecified.
Usage rights and data terms
The page does not establish commercial audio-use rights, output ownership, a documentation or sample-code redistribution licence, or data retention and training terms. These remain unknown.
Custom voices from short reference clips are mentioned, but consent, identity verification and authorization requirements are not explained here. The ability to supply a custom voice ID does not establish permission to reproduce a particular person's voice.
Documentation freshness
The documentation was captured on 24 November 2026 at 00:37:52 UTC. The page supplies no publication date, last-update date or synthesis-model version, so the age of individual features is unknown.
The capture establishes what the documentation stated at that time. Current endpoint behavior, voice availability, limits and commercial terms are not independently established.
Useful next steps
Audition the intended voices and language variants in the playground at [https://console.x.ai/team/default/voice/text-to-speech]. Confirm synthesis prices, audio-use rights and data terms with the provider before committing to an integration. For custom voices, establish authorization requirements for the reference audio.
For an initial implementation, use a short HTTP request and browser-compatible output. Before adopting streaming, evaluate interruption handling, chunk-boundary quality, concurrency and session lifetime. Applications using captions should also evaluate alignment with normalization and replacements enabled. These are recommended evaluations, not completed tests.
