Grok CLI Manual

Download and Install

Install the CLI with xAI's official installer, then configure XAI Router from inside your project environment.

Linux / macOS

Use the official xAI installer:

curl -fsSL https://x.ai/cli/install.sh | bash
grok --version

Update an existing installation:

grok update

grok update --check only checks whether a newer version exists.

npm

With Node.js 20 or later installed, you can also use xAI's official npm package:

npm install -g @xai-official/grok
grok --version

Windows

On native Windows, use the official PowerShell installer or the npm package:

irm https://x.ai/cli/install.ps1 | iex

PowerShell, Git Bash, and WSL are supported. If your projects and toolchain primarily run on Linux, you can instead install Grok inside WSL2 with the Linux instructions above.

Native Windows and WSL2 are separate environments. Install and configure Grok in the environment where you actually run it.

Sign-in

This site uses an XAI Router Key set in the config file (see Connect to XAI Router). For reference, the official sign-in options are browser sign-in on your own machine, grok login --device-auth over SSH or on remote hosts, and the XAI_API_KEY variable for CI and scripts.

Verify installation

grok --version
grok --help
grok inspect

If the shell reports grok: command not found, reopen the terminal and verify that the installation directory is on PATH.

Official resources: xAI Grok Build ยท @xai-official/grok