explaingit

moore-developers/grok-cli

13RustAudience · developerComplexity · 2/5ActiveSetup · easy

TLDR

Rust CLI that talks to Grok and xAI from the terminal using your SuperGrok or X Premium+ OAuth login, with chat, search, image, video, and speech commands.

Mindmap

mindmap
  root((grok-cli))
    Inputs
      OAuth login
      Chat prompts
      Media files
    Outputs
      Streaming text
      Generated images
      Generated videos
      Audio files
    Use Cases
      Chat with Grok
      Search X posts
      Generate images
      Transcribe speech
    Tech Stack
      Rust
      OAuth
      SQLite
      WebSocket

Things people build with this

USE CASE 1

Chat with Grok from the terminal using your existing SuperGrok or X Premium+ account

USE CASE 2

Generate, edit, and extend images and videos with xAI from a shell script

USE CASE 3

Run text-to-speech and streaming speech-to-text over WebSocket

USE CASE 4

Wire grok-cli into AI agents like Cursor or Claude Code through a bundled npx skill

Tech stack

RustOAuthSQLiteWebSocket

Getting it running

Difficulty · easy Time to first run · 5min

OAuth login uses an existing SuperGrok or X Premium+ account, so no separate paid API key is needed.

In plain English

grok-cli is a command-line tool, written in Rust, for talking to Grok and the xAI service from a terminal window instead of a web browser. The key idea is that you sign in once with your existing SuperGrok or X Premium+ account using OAuth (an in-browser login flow), so you do not need a separate paid API key. The tool gathers many xAI features behind a single, flat command surface. There are commands for login and session management (login, status, refresh, logout, state), a chat command that streams readable answers by default (with web search included), and a search command that queries X posts. There are also generation commands for images (image, image-edit), videos (video, video-edit, video-extend), text-to-speech (tts), and speech-to-text (stt and stt-stream over WebSocket, marked experimental). A usage command shows your local session totals and recent rate-limit snapshots. The authors target three kinds of users in the README. Humans get streaming text answers and simple positional arguments. Scripts can pass --json to get a stable, non-streaming envelope of the form {ok, command, data} or {ok, command, error}. AI agents (Codex, Claude Code, Cursor, OpenClaw, Hermes Agent, and similar runtimes) can install a bundled skill via npx so the assistant handles install checks, OAuth login, and command routing. Installation is offered three ways: install the skill, build from source with cargo (Rust 1.88 or newer, repository pinned to 1.92.0), or download a prebuilt binary for macOS Apple Silicon or Windows x64. Local state lives under ~/.grok-cli, with OAuth tokens in auth.json and usage history in a SQLite file. Media file bodies are not stored in SQLite.

Copy-paste prompts

Prompt 1
Install grok-cli with cargo and run the login command to authenticate with my SuperGrok account
Prompt 2
Use grok-cli chat with --json to get a stable envelope I can pipe into a shell script
Prompt 3
Generate an image with grok-cli image and then edit it with grok-cli image-edit
Prompt 4
Install the grok-cli skill into Claude Code with npx and let the agent route commands
Prompt 5
Where does grok-cli store OAuth tokens and usage history, and how do I rotate them
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.