OpenClaw Reference (Mirrored)

xAI

Mirrored from OpenClaw (MIT)
This mirror is provided for convenience. OpenClawdBots is not affiliated with or endorsed by OpenClaw.

xAI

OpenClaw ships a bundled xai provider plugin for Grok models.

Getting started

  1. Create an API key

    Create an API key in the xAI console.

  2. Set your API key

    Set XAI_API_KEY, or run:

    openclaw onboard --auth-choice xai-api-key
    
  3. Pick a model
    {
      agents: { defaults: { model: { primary: "xai/grok-4" } } },
    }
    
NOTE

OpenClaw uses the xAI Responses API as the bundled xAI transport. The same XAI_API_KEY can also power Grok-backed web_search, first-class x_search, and remote code_execution. If you store an xAI key under plugins.entries.xai.config.webSearch.apiKey, the bundled xAI model provider reuses that key as a fallback too. code_execution tuning lives under plugins.entries.xai.config.codeExecution.

Bundled model catalog

OpenClaw includes these xAI model families out of the box:

FamilyModel ids
Grok 3grok-3, grok-3-fast, grok-3-mini, grok-3-mini-fast
Grok 4grok-4, grok-4-0709
Grok 4 Fastgrok-4-fast, grok-4-fast-non-reasoning
Grok 4.1 Fastgrok-4-1-fast, grok-4-1-fast-non-reasoning
Grok 4.20 Betagrok-4.20-beta-latest-reasoning, grok-4.20-beta-latest-non-reasoning
Grok Codegrok-code-fast-1

The plugin also forward-resolves newer grok-4* and grok-code-fast* ids when they follow the same API shape.

TIP

grok-4-fast, grok-4-1-fast, and the grok-4.20-beta-* variants are the current image-capable Grok refs in the bundled catalog.

Fast-mode mappings

/fast on or agents.defaults.models["xai/<model>"].params.fastMode: true rewrites native xAI requests as follows:

Source modelFast-mode target
grok-3grok-3-fast
grok-3-minigrok-3-mini-fast
grok-4grok-4-fast
grok-4-0709grok-4-fast

Legacy compatibility aliases

Legacy aliases still normalize to the canonical bundled ids:

Legacy aliasCanonical id
grok-4-fast-reasoninggrok-4-fast
grok-4-1-fast-reasoninggrok-4-1-fast
grok-4.20-reasoninggrok-4.20-beta-latest-reasoning
grok-4.20-non-reasoninggrok-4.20-beta-latest-non-reasoning

Features

Web search

The bundled grok web-search provider uses XAI_API_KEY too:

openclaw config set tools.web.search.provider grok
Video generation

The bundled xai plugin registers video generation through the shared video_generate tool.

  • Default video model: xai/grok-imagine-video
  • Modes: text-to-video, image-to-video, and remote video edit/extend flows
  • Supports aspectRatio and resolution
WARNING

Local video buffers are not accepted. Use remote http(s) URLs for video-reference and edit inputs.

To use xAI as the default video provider:

{
  agents: {
    defaults: {
      videoGenerationModel: {
        primary: "xai/grok-imagine-video",
      },
    },
  },
}
NOTE

See Video Generation for shared tool parameters, provider selection, and failover behavior.

x_search configuration

The bundled xAI plugin exposes x_search as an OpenClaw tool for searching X (formerly Twitter) content via Grok.

Config path: plugins.entries.xai.config.xSearch

KeyTypeDefaultDescription
enabledbooleanEnable or disable x_search
modelstringgrok-4-1-fastModel used for x_search requests
inlineCitationsbooleanInclude inline citations in results
maxTurnsnumberMaximum conversation turns
timeoutSecondsnumberRequest timeout in seconds
cacheTtlMinutesnumberCache time-to-live in minutes
{
  plugins: {
    entries: {
      xai: {
        config: {
          xSearch: {
            enabled: true,
            model: "grok-4-1-fast",
            inlineCitations: true,
          },
        },
      },
    },
  },
}
Code execution configuration

The bundled xAI plugin exposes code_execution as an OpenClaw tool for remote code execution in xAI's sandbox environment.

Config path: plugins.entries.xai.config.codeExecution

KeyTypeDefaultDescription
enabledbooleantrue (if key available)Enable or disable code execution
modelstringgrok-4-1-fastModel used for code execution requests
maxTurnsnumberMaximum conversation turns
timeoutSecondsnumberRequest timeout in seconds
NOTE

This is remote xAI sandbox execution, not local exec.

{
  plugins: {
    entries: {
      xai: {
        config: {
          codeExecution: {
            enabled: true,
            model: "grok-4-1-fast",
          },
        },
      },
    },
  },
}
Known limits
  • Auth is API-key only today. There is no xAI OAuth or device-code flow in OpenClaw yet.
  • grok-4.20-multi-agent-experimental-beta-0304 is not supported on the normal xAI provider path because it requires a different upstream API surface than the standard OpenClaw xAI transport.
Advanced notes
  • OpenClaw applies xAI-specific tool-schema and tool-call compatibility fixes automatically on the shared runner path.
  • Native xAI requests default tool_stream: true. Set agents.defaults.models["xai/<model>"].params.tool_stream to false to disable it.
  • The bundled xAI wrapper strips unsupported strict tool-schema flags and reasoning payload keys before sending native xAI requests.
  • web_search, x_search, and code_execution are exposed as OpenClaw tools. OpenClaw enables the specific xAI built-in it needs inside each tool request instead of attaching all native tools to every chat turn.
  • x_search and code_execution are owned by the bundled xAI plugin rather than hardcoded into the core model runtime.
  • code_execution is remote xAI sandbox execution, not local exec.