Skip to main content
Run an Agent through your xAI subscription by delegating turns to the grok CLI. The Agent sends each turn to grok, which uses your xAI subscription login — no XAI_API_KEY required.

Quick Start

1

Install the Grok CLI

2

Run an Agent through Grok

cli_backend= is deprecated (removal in 2.0.0). Prefer runtime="grok-cli" — see Runtime Selection.

How It Works

Each turn spawns grok with your subscription session. No API key is passed.

Use as Agent Backend

Delegate an Agent’s LLM turns to grok -p instead of the xAI API — uses your xAI subscription.

Backend Configuration

The grok-cli backend ships with this default configuration:

Backend CLI Flags

The backend builds the grok command with these flags:

Session Resume

The backend forwards --resume <session_id> only when the session is a resume — it checks session.is_resume before adding the flag. First turns start fresh.

Configuration Surfaces

Override the default timeout (or any config field) with the dict form:
Declare it in YAML for versioned configuration:

Best Practices

Run grok login before your first Agent turn. The backend uses whatever subscription session the CLI is signed into — no XAI_API_KEY needed.
The default timeout_ms is 5 minutes. For long-running turns, override it:
Pass image paths and the backend forwards each as --image <path>. Useful for visual tasks the model can inspect.
cli_backend= still works but emits a DeprecationWarning. Use runtime="grok-cli" for the modern equivalent, or run praisonai doctor fix --execute to migrate YAML.

Robustness (PR #4111)

  • A subprocess TimeoutError is now returned as CliBackendResult(error=...) instead of escaping as an exception.
  • On CalledProcessError, the CLI’s actual stderr diagnostic is surfaced (previously only the exit status was shown).
  • --model and cwd are threaded through, so scheduled runs can pin a model and run in a workspace.
  • CliSessionBinding.is_resume is now set on the second turn of a session, so the resume branch runs instead of re-sending the system prompt every turn.

Codex CLI

Delegate Agent turns to OpenAI’s Codex CLI using your ChatGPT subscription.

Gemini CLI

Delegate Agent turns to Google’s Gemini CLI using your Google account.

Claude Code

The flagship CLI backend — works with Claude Pro / Max subscriptions.

CLI Backend Protocol

How CLI backends plug into the Agent API.