grokbot_api
Version 1.1.0 · Tests: 117 unit and integration tests and 36 doctests, all passing ·
Coverage: 99% of lines (cargo llvm-cov --all-features) · MSRV: Rust 1.89
An unofficial async Rust client for the Grok Bot gateway: the private API behind the Grok Bot desktop app that lists your bots, sends them prompts and reads their replies.
It gives you typed calls for every known gateway method, plus the pieces needed to use them:
- Sessions. Turn a Cursor access token into a gateway session with EnsureSandBox, and re-authenticate automatically when the session expires.
- Safety. A host allowlist ensures credentials only go to Cursor hosts, and error messages never contain secrets.
- Delivery. Each send reports whether the prompt landed: accepted, rejected or unknown.
- Transcripts. Page through chat history and detect approval cards.
- Desktop app (opt-in). Reuse the desktop app's saved login.
Unofficial and undocumented. The gateway has no public documentation. This crate mirrors what grok-bot-cli and the desktop app do, and the API may change without notice. It is not affiliated with or endorsed by the makers of Grok Bot or Cursor.
Install
[]
= "1"
= { = "1", = ["macros", "rt-multi-thread"] }
# Optional: read the Grok Bot desktop app's saved session.
# grokbot_api = { version = "1", features = ["desktop-session"] }
Or cargo add grokbot_api tokio --features tokio/macros,tokio/rt-multi-thread.
The client uses reqwest with rustls; it needs a Tokio runtime.
Examples
List your bots with a gateway session:
use ;
async
Log in with a Cursor access token, send a prompt and read the transcript:
use ;
async
Check where credentials may be sent (no network):
use Policy;
let policy = default;
assert!;
assert!;
More in examples/. cargo run --example mock_gateway runs the whole flow
offline against a mock server.
Table of contents
| Guide | What it covers |
|---|---|
| Sessions and authentication | Gateway sessions, EnsureSandBox, client identity, 401/417 re-authentication, ClientOptions |
| Credential policy | The host allowlist, loopback gateways, GROKBOT_ALLOW_LOCAL_GATEWAY |
| Agents, groups and team agents | Listing, creating, updating and deleting bots; groups; team bots shared with you |
| Sending prompts and delivery | send_prompt, nonces, Delivery, promptAcceptanceStatus, waiting for replies |
| Transcripts | Tail pages, beforeSeq paging, full history, threads, entry parsing, sanitizing |
| Approvals | Detecting approval cards and resolving them (on a user's decision only) |
| Workflows (skills) | Listing, importing and deleting skills |
| Errors, limits and redaction | Error variants, delivery mapping, timeouts, size caps, secret redaction |
| Desktop session | The opt-in desktop-session feature: reading the desktop app's saved login |
| Wire protocol | Endpoints, headers, every method's request body, call_raw |
On docs.rs the same guides are in the
guide module.
Development
RUSTDOCFLAGS="-D warnings"
The tests never contact the real gateway and use only fake tokens. A few branches are not covered:
- code that only runs on another OS (the Windows DPAPI path)
- fixed system install paths such as
/opt/Grok Bot reqwestclient construction failures
See CHANGELOG.md for release notes.
License
BSD 3-Clause. See LICENSE.