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

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 zeroruntime.plugins import XAILLM

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

  # Pipeline(llm=llm, ...)
  ```

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

  const llm = XAILLM({
    model: 'grok-4-1-fast-non-reasoning',
    temperature: 0.7,
  });

  // Pipeline({ llm, ... })
  ```
</CodeGroup>

## Configuration Options

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

| 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 zeroruntime.plugins import XAILLM` | `XAILLM(...)` |
| Node JS | `import { XAILLM } from '@zeroruntime/js-sdk/plugins'` | `XAILLM({ ... })` |

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


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