> ## 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 LLM plugin in a Zero Runtime pipeline. Setup, options, and usage in Python, JavaScript, and Go.

xAI Grok is an **LLM** plugin. It takes the transcribed conversation and generates the
reply using xAI's Grok models, with client-side function calling.

## 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

Import the plugin and pass it to the pipeline's `llm` slot.

<CodeGroup>
  ```python Python theme={null}
  from zrt.plugins import XAILLM

  llm = XAILLM(
      model="grok-4-1-fast-non-reasoning",
      temperature=0.7,
  )

  # Pipeline(llm=llm, ...)
  ```
</CodeGroup>

## Configuration Options

*Constructor parameters for the Python SDK (`XAILLM`). The JavaScript and Go SDKs expose equivalent options where supported, in their idiomatic form (camelCase / `LLMOptions` struct).*

| Parameter               | Type    | Default                         | Description                                                                   |
| ----------------------- | ------- | ------------------------------- | ----------------------------------------------------------------------------- |
| `api_key`               | `str`   | `None`                          | xAI API key. Falls back to the `XAI_API_KEY` environment variable when unset. |
| `model`                 | `str`   | `"grok-4-1-fast-non-reasoning"` | Grok model used to generate replies (e.g. `grok-4`, `grok-4-1-fast`).         |
| `base_url`              | `str`   | `"https://api.x.ai/v1"`         | xAI API base URL.                                                             |
| `temperature`           | `float` | `0.7`                           | Sampling randomness; lower is more deterministic.                             |
| `tool_choice`           | `str`   | `"auto"`                        | How the model decides when to call tools.                                     |
| `max_completion_tokens` | `int`   | `None`                          | Caps the length of each reply.                                                |

## Import paths

| SDK        | Import                           | Constructor                       |
| ---------- | -------------------------------- | --------------------------------- |
| Python     | `from zrt.plugins import XAILLM` | `XAILLM(...)`                     |
| JavaScript | `from '@zrt/js-sdk/plugins/xai'` | `XAILLM({ ... })`                 |
| Go         | `.../zrt-golang-sdk/plugins/xai` | `xai.NewLLM(xai.LLMOptions{...})` |

The reply is streamed to the [text-to-speech](/plugins/tts/cartesia) plugin, which
synthesizes the agent's voice.
