Grok CLI Manual
Download and Install
Install the CLI with xAI's official installer, then configure YAI Router from inside your project environment.
Linux / macOS
Use the official xAI installer:
curl -fsSL https://x.ai/cli/install.sh | bash
grok --versionUpdate an existing installation:
grok updatenpm
With Node.js 20 or later installed, you can also use xAI's official npm package:
npm install -g @xai-official/grok
grok --versionWindows
Use the npm package on native Windows. 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.
Verify installation
grok --version
grok --help
grok inspectIf 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