Skip to main content

xAI TTS plugin guide

How to use xAI TTS with LiveKit Agents.

Use in Agent Builder

Create a new agent in your browser using this model

Overview

xAI TTS is available in LiveKit Agents through LiveKit Inference and the xAI plugin. Pricing for LiveKit Inference is available on the pricing page.

Model nameModel IDLanguages
Text to Speech
xai/tts-1
autoenar-EGar-SAar-AEbnzhfrdehiiditjakopt-BRpt-PTrues-MXes-EStrvi

LiveKit Inference

Use LiveKit Inference to access xAI TTS without a separate xAI API key.

Usage

To use xAI, pass a descriptor with the voice to the tts argument in your AgentSession:

from livekit.agents import AgentSession
session = AgentSession(
tts="xai/tts-1:ara",
# ... stt, llm, vad, turn_detection, etc.
)

Parameters

To customize additional parameters, use the TTS class from the inference module:

from livekit.agents import AgentSession, inference
session = AgentSession(
tts=inference.TTS(
model="xai/tts-1",
voice="ara",
language="en"
),
# ... stt, llm, vad, turn_detection, etc.
)
voicestringRequired

The voice ID used for speech generation. For guidance on selecting a voice, see voices.

languagestringOptional

Language code for the input text. If not set, the model default applies.

Voices

The following is a sample of the xAI voices available in LiveKit Inference. For a complete list of voices, see the xAI TTS documentation.

Ara

Warm, friendly

🇺🇸
Eve

Energetic, upbeat

🇺🇸
Leo

Authoritative, strong

🇺🇸
Rex

Confident, clear

🇺🇸

Plugin

Use the xAI plugin to connect directly to xAI's TTS API with your own API key.

Available in
Python

Installation

Install the plugin from PyPI:

uv add "livekit-agents[xai]~=1.4"

Authentication

The xAI plugin requires an xAI API key.

Set XAI_API_KEY in your .env file.

Usage

Use xAI TTS in an AgentSession or as a standalone speech generator. For example, you can use this TTS in the Voice AI quickstart.

from livekit.plugins import xai
session = AgentSession(
tts = xai.TTS(
voice="ara",
),
# ... llm, stt, etc.
)

Parameters

This section describes some of the available parameters. See the plugin reference links in the Additional resources section for a complete list of all available parameters.

voiceGrokVoices | stringOptionalDefault: ara

The voice ID used for speech generation.

Speech tags

xAI TTS supports speech tags that add expressive delivery to synthesized speech. There are two categories of tags:

  • Inline tags insert a vocal expression at a specific point in the text. For example, a [pause] tag can create a short pause, while a [laugh] tag can add laughter.
  • Wrapping tags modify how a section of text is delivered. For example, <whisper>a secret</whisper> delivers the text in a whispered voice, while <slow>text</slow> is spoken at a slower pace.

Tags can be combined for layered effects:

So I walked in and [pause] there it was. [laugh]
I need to tell you something. <whisper>It is a secret.</whisper>
<slow><soft>Goodnight, sleep well.</soft></slow>

For a complete list of tags and examples, see the xAI speech tags documentation.

Additional resources

The following resources provide more information about using xAI with LiveKit Agents.