> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# xAI Grok

> Use the xAI Grok speech-to-speech model in a Zero Runtime pipeline. Setup and usage in Python.

xAI Grok Realtime is a **speech-to-speech** model. It handles transcription, reasoning, and
voice synthesis end-to-end in a single model, so it goes in the pipeline's `llm` slot with
no separate STT or TTS. The `Pipeline` auto-detects [Realtime mode](/build/configure-a-pipeline/modes)
when you pass it.

## Setup

Set your xAI API key in the worker environment. Generate a key from the [xAI console](https://console.x.ai):

```bash theme={null}
export XAI_API_KEY=<key>
```

## Usage

Pass the realtime model to the pipeline's `llm` slot, no `stt` or `tts` needed.

```python theme={null}
from zrt import Pipeline
from zrt.plugins import XaiRealtime, XaiRealtimeConfig

llm = XaiRealtime(
    config=XaiRealtimeConfig(
        model="grok-realtime",
        voice="Ara",
        modalities=["text", "audio"],
    ),
)

pipeline = Pipeline(llm=llm)
```

## Parameters

*Constructor parameters for the Python SDK (`XaiRealtime`).*

| Parameter | Type                | Default | Description                                                                                    |
| --------- | ------------------- | ------- | ---------------------------------------------------------------------------------------------- |
| `api_key` | `str`               | `None`  | xAI API key. Falls back to the `XAI_API_KEY` environment variable when unset.                  |
| `config`  | `XaiRealtimeConfig` | `None`  | Model behavior configuration (see below). When omitted, a default `XaiRealtimeConfig` is used. |

### `XaiRealtimeConfig`

| Field                        | Type                            | Default                  | Description                                                                                                                     |
| ---------------------------- | ------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `model`                      | `str`                           | `"grok-realtime"`        | Grok realtime model ID.                                                                                                         |
| `voice`                      | `str`                           | `"Ara"`                  | Output voice. One of `"Ara"`, `"Rex"`, `"Sal"`, `"Eve"`, `"Leo"`.                                                               |
| `modalities`                 | `list[str]`                     | `["text", "audio"]`      | Enabled response types. Drop `"audio"` for text-only.                                                                           |
| `temperature`                | `float`                         | `0.8`                    | Sampling randomness.                                                                                                            |
| `max_response_output_tokens` | `int \| str`                    | `"inf"`                  | Caps the length of each response. `"inf"` disables the cap.                                                                     |
| `turn_detection`             | `TurnDetectionConfig`           | server VAD               | Turn detection (`server_vad`, threshold `0.5`, `prefix_padding_ms` `300`, `silence_duration_ms` `200`). Pass `None` to disable. |
| `input_audio_transcription`  | `InputAudioTranscriptionConfig` | `gpt-4o-mini-transcribe` | Transcription model for the user's audio.                                                                                       |
| `tool_choice`                | `str`                           | `"auto"`                 | How the model decides when to call tools.                                                                                       |
| `base_url`                   | `str`                           | `None`                   | Override the xAI realtime API base URL.                                                                                         |

To pair the realtime model with an external STT or TTS, see [Hybrid mode](/build/configure-a-pipeline/modes#hybrid). For general plugin concepts, see the [plugins overview](/plugins/overview).
