@standardagents/xai
xAI provider package for Standard Agents using the official @ai-sdk/xai package
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.
- Official
@ai-sdk/xaiintegration - Grok chat model streaming, reasoning, and tool calls
- xAI provider-executed tools such as
web_search,x_search, andcode_execution - xAI image generation and image editing support
- Built-in pricing for documented Grok text models
- Request inspection support in the admin UI
Installation
pnpm add @standardagents/xaiQuick 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-0709grok-4-fast-reasoninggrok-4-1-fast-reasoninggrok-code-fast-1grok-3grok-imagine-imagegrok-imagine-image-pro
Provider Options
Chat options include reasoningEffort, logprobs, topLogprobs, 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:
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
XAI_API_KEY=...