grok.md
1 # Grok 2 3 **Mode**: Default Grok adapter + optional explicit consumer web path ยท **Domain**: `grok.com` 4 5 ## Commands 6 7 | Command | Description | 8 |---------|-------------| 9 | `opencli grok ask` | Keep the default Grok ask behavior | 10 | `opencli grok ask --web` | Use the explicit grok.com consumer web UI flow | 11 | `opencli grok image` | Generate images via the Grok web UI and return the latest image URLs | 12 13 ## Usage Examples 14 15 ```bash 16 # Default / compatibility path 17 opencli grok ask --prompt "Explain quantum computing in simple terms" 18 19 # Explicit consumer web path 20 opencli grok ask --prompt "Explain quantum computing in simple terms" --web 21 22 # Best-effort fresh chat on the consumer web path 23 opencli grok ask --prompt "Hello" --web --new 24 25 # Set custom timeout (default: 120s) 26 opencli grok ask --prompt "Write a long essay" --web --timeout 180 27 28 # Generate an image and return the URLs 29 opencli grok image "a cyberpunk mechanical owl, neon purple and blue" --new true 30 31 # Save generated images to disk 32 opencli grok image "a watercolor lighthouse on a cliff" --out /tmp/grok-img --timeout 300 33 ``` 34 35 ### Options 36 37 | Option | Description | 38 |--------|-------------| 39 | `--prompt` | The message to send (required) | 40 | `--timeout` | Wait timeout in seconds (default: 120) | 41 | `--new` | Start a new chat before sending (default: false) | 42 | `--web` | Opt into the explicit grok.com consumer web flow (default: false) | 43 | `--count` | Minimum images to wait for before returning (default: 1, `image` only) | 44 | `--out` | Directory to save generated images to disk (`image` only) | 45 46 ## Behavior 47 48 - `opencli grok ask` keeps the upstream/default behavior intact. 49 - `opencli grok ask --web` switches to the newer hardened consumer-web implementation. 50 - The `--web` path adds stricter composer detection, clearer blocked/session-gated hints, and waits for a stabilized assistant bubble before returning. 51 - `opencli grok image` reuses the existing browser-backed Grok session, waits for the latest assistant image bubble to stabilize, and can optionally download the resulting images through the authenticated page context. 52 53 ## Prerequisites 54 55 - The Grok adapter still depends on browser-backed access to `grok.com` 56 - For `--web`, Chrome should already be running with an authenticated Grok consumer session 57 - [Browser Bridge extension](/guide/browser-bridge) installed 58 59 ## Caveats 60 61 - `--web` drives the Grok consumer web UI in the browser, not an API. 62 - It depends on an already-authenticated session and can fail if Grok shows login, challenge, rate-limit, or other session-gating UI. 63 - It may break when the Grok composer DOM, submit button behavior, or message bubble structure changes.