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

# @standardagents/xai

> xAI provider package for Standard Agents using the official @ai-sdk/xai package

> [!NOTE]
>
> **Enabled when** `XAI_API_KEY` is set in your environment.

## Overview

The `@standardagents/xai` package provides a Standard Agents provider for Grok chat and image models. It uses the official `@ai-sdk/xai` package, supports Grok streaming responses, and routes `grok-imagine-image*` models through xAI's image generation/edit APIs.

> [card] Key Features
>
> * Official `@ai-sdk/xai` integration
> * Grok chat model streaming, reasoning, and tool calls
> * xAI provider-executed tools such as `web_search`, `x_search`, and `code_execution`
> * xAI image generation and image editing support
> * Built-in pricing for documented Grok text models
> * Request inspection support in the admin UI

## Installation

```bash pnpm theme={null}
pnpm add @standardagents/xai
```

## Quick Start

```typescript theme={null}
import { defineModel } from '@standardagents/spec';
import { xai } from '@standardagents/xai';

export default defineModel({
  name: 'grok-default',
  provider: xai,
  model: 'grok-4-0709',
  providerOptions: {
    reasoningEffort: 'high',
  },
});
```

## Common Models

* `grok-4-0709`
* `grok-4-fast-reasoning`
* `grok-4-1-fast-reasoning`
* `grok-code-fast-1`
* `grok-3`
* `grok-imagine-image`
* `grok-imagine-image-pro`

## Provider Options

Chat options include `reasoningEffort`, `logprobs`, `topLogprobs`, `parallel_function_calling`, `searchParameters`, `store`, and `previousResponseId`.

Image options include `aspect_ratio`, `output_format`, `resolution`, `quality`, and `numberOfImages`.

## Provider Tools

xAI built-in tools are provider-executed. Enable provider-defined names on the
model and select them from prompts:

```typescript theme={null}
export default defineModel({
  name: 'grok-research',
  provider: xai,
  model: 'grok-4-0709',
  providerTools: ['x_search', 'web_search', 'code_execution'],
});
```

Image and video understanding helpers are modeled as provider tool names in
Standard Agents Builder and translated by `@standardagents/xai` into the corresponding xAI
search-tool options. Completed xAI tool calls are reported through the generic
Standard Agents provider-tool log path, not the local function executor.

## Environment Setup

```bash .dev.vars theme={null}
XAI_API_KEY=...
```


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