> ## 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 and JavaScript.

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](/runtime-sdk/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.

<CodeGroup>
  ```python Python theme={null}
  from zeroruntime import Pipeline
  from zeroruntime.plugins import XAIRealtime

  llm = XAIRealtime(
      model="grok-realtime",
      config={
          "voice": "Ara",
          "modalities": ["text", "audio"],
      },
  )

  pipeline = Pipeline(llm=llm)
  ```

  ```typescript Node JS theme={null}
  import { Pipeline } from '@zeroruntime/js-sdk';
  import { XAIRealtime } from '@zeroruntime/js-sdk/plugins';

  const llm = XAIRealtime({
    model: 'grok-realtime',
    config: {
      voice: 'Ara',
      modalities: ['text', 'audio'],
    },
  });

  const pipeline = Pipeline({ llm });
  ```
</CodeGroup>

## Parameters

*Constructor parameters for `XAIRealtime`. The Python and Node JS SDKs share these field names.*

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"grok-realtime"` | Grok realtime model ID. |
| `api_key` | `str` | `None` | xAI API key. Falls back to the `XAI_API_KEY` environment variable when unset. |
| `config` | `dict` | `None` | Model behavior configuration (see below). When omitted, provider defaults are used. |

### `config` keys

| Field | Type | Default | Description |
| - | - | - | - |
| `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](/runtime-sdk/build/configure-a-pipeline/modes#hybrid). For general plugin concepts, see the [plugins overview](/runtime-sdk/plugins/overview).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.