LiveKit docs › Partner spotlight › xAI › xAI STT

---

# xAI STT

> How to use xAI STT with LiveKit Agents.

- **[Use in Agent Builder](https://cloud.livekit.io/projects/p_/agents/builder/new?stt=xai%2Fstt-1)**: Create a new agent in your browser using xai/stt-1

## Overview

xAI speech-to-text is available in LiveKit Agents through [LiveKit Inference](https://docs.livekit.io/agents/models/inference.md) and the [xAI plugin](#plugin). With LiveKit Inference, your agent runs on LiveKit's infrastructure to minimize latency. No separate provider API key is required, and usage and rate limits are managed through LiveKit Cloud. Use the plugin instead if you want to manage your own billing and rate limits. Pricing for LiveKit Inference is available on the [pricing page](https://livekit.com/pricing/inference#stt).

## LiveKit Inference

Use [LiveKit Inference](https://docs.livekit.io/agents/models/inference.md) to access xAI STT without a separate xAI API key.

| Model name | Model ID | Languages |
| -------- | -------- | --------- |
| Speech to Text | `xai/stt-1` | `en`, `ar`, `cs`, `da`, `nl`, `fr`, `de`, `hi`, `id`, `it`, `ja`, `ko`, `ms`, `fa`, `pl`, `pt`, `ro`, `ru`, `es`, `sv`, `th`, `tr`, `vi`, `fil`, `mk` |

### Usage

To use xAI, use the `STT` class from the `inference` module:

**Python**:

```python
from livekit.agents import AgentSession, inference

session = AgentSession(
    stt=inference.STT(
        model="xai/stt-1",
        language="en"
    ),
    # ... llm, tts, vad, turn_handling, etc.
)

```

---

**Node.js**:

```typescript
import { AgentSession, inference } from '@livekit/agents';

const session = new AgentSession({
    stt: new inference.STT({
        model: "xai/stt-1",
        language: "en"
    }),
    // ... llm, tts, vad, turnHandling, etc.
});

```

### Parameters

- **`model`** _(string)_: The model to use for the STT. See [model IDs](#inference) for available models.

- **`language`** _(LanguageCode)_ (optional): [Language code](https://docs.livekit.io/agents/models/stt.md#language-codes) for the transcription. If not set, the provider default applies.

- **`extra_kwargs`** _(dict)_ (optional): Additional parameters to pass to the xAI STT API. See [model parameters](#model-parameters) for supported fields.

In Node.js this parameter is called `modelOptions`.

#### Model parameters

Pass the following parameters inside `extra_kwargs` (Python) or `modelOptions` (Node.js):

| Parameter | Type | Default | Notes |
| diarize | `bool` | `False` | Set to `True` to enable [speaker diarization](#speaker-diarization). |
| endpointing | `int` |  | Duration of silence in milliseconds before an utterance is considered final. Valid range: `0`–`5000`. |
| format | `bool` |  | Whether to apply inverse text normalization (for example, `"one hundred dollars"` → `"$100"`). Requires [`language`](#language) to be set. |
| interim_results | `bool` | `True` | Whether to return in-progress transcription results before the final transcript. Disable to reduce the number of messages at the cost of higher latency. |

### String descriptors

As a shortcut, you can also pass a [model ID](#inference) string directly to the `stt` argument in your `AgentSession`:

**Python**:

```python
from livekit.agents import AgentSession

session = AgentSession(
    stt="xai/stt-1:en",
    # ... llm, tts, vad, turn_handling, etc.
)

```

---

**Node.js**:

```typescript
import { AgentSession } from '@livekit/agents';

const session = new AgentSession({
    stt: "xai/stt-1:en",
    // ... llm, tts, vad, turnHandling, etc.
});

```

## Plugin

LiveKit's plugin support for xAI lets you connect directly to xAI's STT API with your own API key.

Available in:
- [x] Node.js
- [x] Python

### Installation

Install the plugin from PyPI or npm:

**Python**:

```shell
uv add "livekit-agents[xai]~=1.5"

```

---

**Node.js**:

```shell
pnpm add @livekit/agents-plugin-xai

```

### Authentication

The xAI plugin requires an [xAI API key](https://console.x.ai/).

Set `XAI_API_KEY` in your `.env` file.

### Usage

Use xAI STT in an `AgentSession` or as a standalone transcription service. For example, you can use this STT in the [Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai.md).

**Python**:

```python
from livekit.plugins import xai

session = AgentSession(
    stt=xai.STT(
        language="en",
    ),
    # ... llm, tts, etc.
)

```

---

**Node.js**:

```typescript
import * as xai from '@livekit/agents-plugin-xai';

const session = new voice.AgentSession({
    stt: new xai.STT({
        language: "en",
    }),
    // ... llm, tts, etc.
});

```

### Parameters

This section describes some of the available parameters. See the plugin reference links in the [Additional resources](#additional-resources) section for a complete list of all available parameters.

- **`api_key`** _(string)_ - Environment: `XAI_API_KEY`: xAI API key.

- **`language`** _(string)_ (optional) - Default: `en`: BCP-47 language code for transcription (for example, `"en"`, `"fr"`, `"de"`).

- **`enable_interim_results`** _(bool)_ (optional) - Default: `True`: Whether to return in-progress transcription results before the final transcript. Disable to reduce the number of messages at the cost of higher latency.

In Node.js this parameter is called `interimResults`.

- **`enable_diarization`** _(bool)_ (optional) - Default: `False`: Set to `True` to enable [speaker diarization](#speaker-diarization).

In Node.js this parameter is called `enableDiarization`.

## Speaker diarization

Enable speaker diarization so the STT assigns a speaker identifier to each word or segment. When enabled, transcript events include a `speaker_id`, and the STT reports `capabilities.diarization = True`.

With diarization enabled, you can wrap the xAI STT with [`MultiSpeakerAdapter`](https://docs.livekit.io/agents/models/stt.md#speaker-diarization) for primary speaker detection and transcript formatting.

Enable speaker diarization in the `STT` constructor:

**LiveKit Inference**:

```python
stt = inference.STT(
    model="xai/stt-1",
    extra_kwargs={
        "diarize": True,
    },
)

```

---

**Plugin**:

```python
stt = xai.STT(
    enable_diarization=True,
)

```

## Additional resources

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

- **[xAI docs](https://docs.x.ai/developers/model-capabilities/audio/speech-to-text)**: xAI STT docs.

- **[Voice AI quickstart](https://docs.livekit.io/agents/start/voice-ai.md)**: Get started with LiveKit Agents and xAI STT.

- **[xAI and LiveKit](https://docs.livekit.io/agents/integrations/xai.md)**: Guide to the xAI and LiveKit Agents integration.

---

This document was rendered at 2026-06-07T11:36:46.452Z.
For the latest version of this document, see [https://docs.livekit.io/agents/models/stt/xai.md](https://docs.livekit.io/agents/models/stt/xai.md).

To explore all LiveKit documentation, see [llms.txt](https://docs.livekit.io/llms.txt).