Share feedback
Answers are generated based on the documentation.

xAI (Grok)

Use xAI's Grok models with docker-agent.

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

The simplest way to use xAI:

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

Named Model

For more control over parameters:

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

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

Available Models

ModelDescriptionContext
grok-3Latest and most capable Grok model131K
grok-3-fastFaster variant with lower latency131K
grok-3-miniCompact model for simpler tasks131K
grok-3-mini-fastFast variant of the mini model131K
grok-2Previous generation model128K
grok-visionVision-capable model32K

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-3-mini) 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:

  • API Type: OpenAI-compatible (openai_chatcompletions)
  • Base URL: https://api.x.ai/v1
  • Token Variable: XAI_API_KEY

Example: Research Assistant

agents:
  researcher:
    model: xai/grok-3
    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