Back to Eliza

xAI Plugin

packages/docs/plugin-registry/llm/xai.md

2.0.12.3 KB
Original Source

The xAI plugin connects Eliza agents to xAI's Grok models, providing access to models with real-time knowledge and strong reasoning capabilities.

Package: @elizaos/plugin-xai

Installation

bash
eliza plugins install @elizaos/plugin-xai

Auto-Enable

The plugin auto-enables when any of the following env vars are present: X_API_KEY, XAI_API_KEY, or GROK_API_KEY.

bash
export XAI_API_KEY=xai-...

Configuration

xAI / Grok Model Settings

Environment VariableRequiredDescription
X_API_KEYYes*Primary key in the plugin registry
XAI_API_KEYYes*Alias — also triggers auto-enable
GROK_API_KEYYes*Alias — also triggers auto-enable
XAI_BASE_URLNoCustom base URL for the xAI API
XAI_MODELNoOverride the default model identifier
XAI_SMALL_MODELNoOverride the small model identifier
XAI_EMBEDDING_MODELNoOverride the embedding model identifier
X_DRY_RUNNoWhen true, all X actions are simulated
X_AUTH_MODENoX auth mode: env (API keys), oauth (OAuth2 PKCE), or bearer
X_ENABLE_POSTNoEnable autonomous posting on X
X_ENABLE_REPLIESNoEnable reply handling on X
X_ENABLE_ACTIONSNoEnable timeline actions (like, repost) on X
X_MAX_POST_LENGTHNoMaximum post length (up to 4000 for premium)

* Any one of X_API_KEY, XAI_API_KEY, or GROK_API_KEY activates the plugin.

eliza.json Example

json
{
  "auth": {
    "profiles": {
      "default": {
        "provider": "xai",
        "model": "grok-3"
      }
    }
  }
}

Supported Models

ModelContextBest For
grok-3131kMost capable, complex reasoning
grok-3-mini131kFast reasoning with thinking mode
grok-2131kGeneral-purpose
grok-2-vision32kImage understanding

Features

  • Streaming responses
  • Tool use / function calling
  • Vision input (Grok 2 Vision)
  • Real-time knowledge from X/Twitter
  • Compatible with OpenAI SDK format
  • Structured JSON output