Skip to main content
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.

Key Features

  • Official @ai-sdk/xai integration
  • Grok chat model streaming, reasoning, and tool calls
  • xAI image generation and image editing support
  • Built-in pricing for documented Grok text models
  • Request inspection support in the admin UI

Installation

pnpm
pnpm add @standardagents/xai

Quick Start

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.

Environment Setup

.dev.vars
XAI_API_KEY=...