Grok CLI

Also called Grok Build. The latest model is available on the free level.

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

This works on Linux (x86_64 and arm64). It downloads the latest stable binary, puts it in ~/.grok/bin/, and usually adds it to your PATH (or creates a symlink).

  1. Verify it worked: grok --version
  2. Launch it: grok
    On first run it opens your browser so you can sign in with your xAI / SuperGrok / X Premium+ account.
  3. For headless / CI use (no browser): export XAI_API_KEY="xai-..." grok -p "your prompt here"

Update later

grok update

Optional: pin a specific version

curl -fsSL https://x.ai/cli/install.sh | bash -s 0.2.117   # example version

Security tip: If you prefer not to pipe straight to bash, download and inspect the script first:

curl -fsSL https://x.ai/cli/install.sh -o install-grok.sh
# review the file, then
bash install-grok.sh

Official docs: docs.x.ai/build/overview and the install page at x.ai/cli.

Context Window

The “XXk / 500k” near the top of the Grok Build CLI shows how much of the current session’s context window has been used so far, out of the model’s maximum.

  • Right now the default model is Grok 4.5, which has a 500,000-token context window.
  • The number updates live as the conversation, tools, files, reasoning, etc. fill the window.
  • It is per-session. Starting a new session (/new or just quitting and relaunching) resets the counter.

Useful commands inside the TUI

  • /context — detailed breakdown (system prompt, messages, tools/skills/MCP overhead, free space, etc.)
  • /usage (or /cost) — session usage / credit info
  • /session-info (or /status) — quick overview including context
  • /compact — compress older history to free up space (it also auto-compacts around ~85%)

Official pages for the limits

There’s also a separate shared weekly usage pool for paid features (including Build). That one is tracked on the web under Settings → Usage (and can be topped up with Extra Usage Credits). The 500k number you see in the CLI is the session context window, not that weekly pool.