These docs track the main branch and may describe unreleased features. The stable documentation lives at docs.docker.com.

xAI (Grok)

Overview

xAI provides the Grok family of models through an OpenAI-compatible API. Docker Agent includes built-in support for xAI as an alias provider.

Setup

  1. Get an API key from xAI Console

  2. Set the environment variable:

    export XAI_API_KEY=your-api-key
    

Usage

Inline Syntax

agents:
  root:
    model: xai/grok-4.5
    description: Assistant using Grok
    instruction: You are a helpful assistant.

Named Model

models:
  grok:
    provider: xai
    model: grok-4.5
    temperature: 0.7
    max_tokens: 8192

agents:
  root:
    model: grok
    description: Assistant using Grok
    instruction: You are a helpful assistant.

Available Models

Model Description Context
grok-4.5 Default Grok model; strong reasoning and tool calling 500K
grok-4.6 Newest Grok release 500K
grok-4.3 Previous generation Grok model 1M

Check the xAI documentation for the latest available models.

Extended Thinking

Docker Agent's thinking_budget field is not applied to xAI models: the underlying OpenAI-compatible client only sends reasoning_effort for OpenAI reasoning model names (o-series, gpt-5). Setting thinking_budget on a Grok model passes config validation but has no effect on the request.

Grok reasoning models (e.g. grok-4.5) reason on their own without configuration. For non-reasoning models, use the think tool instead.

How It Works

xAI is implemented as a built-in alias in Docker Agent:

Example: Research Assistant

agents:
  researcher:
    model: xai/grok-4.5
    description: Research assistant with real-time knowledge
    instruction: |
      You are a research assistant using Grok.
      Provide well-researched, factual responses.
      Cite sources when available.
    toolsets:
      - type: mcp
        ref: docker:duckduckgo
      - type: think