Skip to main content
Lesson 3 of 14 · Text-to-Speech API

List the available voices

Lesson 3 of 14 Updated November 3, 2026 Developer
On this page
  1. Discover voices programmatically
  2. GET /v1/tts/voices
  3. GET /v1/tts/voices/${voice_id}
  4. Choose the right voice
  5. Build voice selection into your app
  6. Best practices
  7. Key takeaways

Updated November 3, 2026, based on the xAI Voice API reference and Text to Speech page: the GET /v1/tts/voices response carries voice_id, name, and language, and xAI offers 28 built-in voices. Sources: Voice API · Text to Speech.

Discover voices programmatically

Rather than hard-coding the list of voices in your app, the xAI API provides a dedicated endpoint for fetching the available voices dynamically. That way, you stay up to date when new voices are added.

GET /v1/tts/voices

This endpoint returns the list of all voices available for TTS. It needs no parameters in the request body.

curl -X GET "https://api.x.ai/v1/tts/voices" \
  -H "Authorization: Bearer $XAI_API_KEY"

The response is a JSON object containing a voices array. According to the API reference, each voice has three fields: voice_id, the lowercase ID to pass in your requests; name, a display name; and language, a language code that can be null.

Response shape

{
  "voices": [
    {"voice_id": "eve", "name": "…", "language": "…"},
    {"voice_id": "ara", "name": "…", "language": "…"}
  ]
}

The ellipses stand in for values the reference doesn’t give as examples: print the real response once before you rely on it. Each voice’s tone and use cases aren’t in this response; they’re described on the xAI Text to Speech page.

GET /v1/tts/voices/{voice_id}

To get the details of a specific voice, add its ID to the path:

curl -X GET "https://api.x.ai/v1/tts/voices/rex" \
  -H "Authorization: Bearer $XAI_API_KEY"

This call returns the same fields (voice_id, name, language) for the requested voice only.

Choose the right voice

xAI offers 28 built-in voices (as of November 3, 2026) and, for most of them, describes what they’re best suited for. A few pointers from that page:

  • Educational content: luna, cosmo, or lumen, listed for education
  • Customer support: carina, iris, rigel, celeste, castor, naksh, or aurora, listed for support
  • Advertising and demos: altair, zenith, perseus, kepler, or lumen, listed for advertising; eve, energetic and upbeat, remains the default voice
  • Narration and audiobooks: orion, zagan, altair, perseus, or lux
  • Wellness: carina, helios, lux, or liora

The five original voices (eve, ara, rex, sal, leo) have no listed use cases: xAI only describes them as energetic and upbeat (British accent), warm and friendly, confident and clear, smooth and balanced, and authoritative and powerful (British accent).

Build voice selection into your app

Here’s an example that loads the available voices dynamically:

import requests

def get_available_voices(api_key):
    response = requests.get(
        "https://api.x.ai/v1/tts/voices",
        headers={"Authorization": f"Bearer {api_key}"}
    )
    response.raise_for_status()
    return response.json()["voices"]

def synthesize(api_key, text, voice_id="eve", language="en"):
    voices = get_available_voices(api_key)
    valid_ids = [v["voice_id"] for v in voices]

    if voice_id.lower() not in valid_ids:
        raise ValueError(f"Unknown voice '{voice_id}'. Available: {valid_ids}")

    response = requests.post(
        "https://api.x.ai/v1/tts",
        headers={"Authorization": f"Bearer {api_key}"},
        json={"text": text, "voice_id": voice_id, "language": language}
    )
    return response.content

This approach protects you from typos in voice IDs and lets you offer your users an up-to-date list.

Best practices

  • Cache the voice list: the /v1/tts/voices endpoint doesn’t change often, so one call when your app starts is enough
  • Offer a preview: let your users listen to a sample of each voice before they choose
  • Save the preference: once a user has picked a voice, store the choice for future sessions
  • Test in the target language: a voice that sounds great in English may sound different in another language. Always test in your app’s language

Key takeaways

  • GET /v1/tts/voices lists all available voices with their metadata
  • GET /v1/tts/voices/{voice_id} gives the details of a specific voice
  • 28 built-in voices are available; their tone and use cases are described on the xAI Text to Speech page
  • The GET /v1/tts/voices response gives voice_id, name, and language for each voice
  • Load voices dynamically rather than hard-coding them