@promptai.credit/cli
v0.2.0
Published
Earn ad-subsidized prompt credits from terminal AI agents (Claude Code). Watch a dev-tool ad while your agent works; verified watches pay your prompt's token cost in USDC.
Maintainers
Readme
promptai CLI
Brings the earn loop (prompt → opt-in ad during the wait → server-side verification → credit → USDC claim) to agents beyond the classic Cursor IDE. Claude Code and the Cursor Agents Window are supported today; Codex CLI is next.
How it works
promptai install claudemerges two hooks into~/.claude/settings.json:- UserPromptSubmit: baselines the session's transcript watermark and (if opted
in, at most every 90s, never headless) opens the hosted rewarded-ad page
(
/watch) in your browser. The ad plays while your agent works. - Stop (async): reads the session transcript JSONL since the watermark, prices the turn with the shared model price table, and redeems one banked server-verified ad session against it via the API.
- UserPromptSubmit: baselines the session's transcript watermark and (if opted
in, at most every 90s, never headless) opens the hosted rewarded-ad page
(
- The
/watchpage creates the ad session server-side on load, so SSV wall-clock timing is enforced by the server; the browser countdown is cosmetic. promptai claimpays out your verified balance as USDC on Base.
Cursor Agents Window (Glass)
The Agents Window doesn't run VS Code extensions, so the promptai extension can't
cover it. promptai install cursor wires beforeSubmitPrompt + stop into
~/.cursor/hooks.json (core Cursor hooks fire in both the Agents Window and the
classic IDE):
- Hook payloads are routed by shape (
cursor_version/conversation_id), so events reach the right adapter even if Cursor loads our Claude-format hooks through its third-party mapping. - Cursor 3.7+ reports real token usage on the
stoppayload (input_tokens,output_tokens, cache splits); cost is priced from that, with cached reads/writes discounted. On older versions the cost falls back to a transcript character-volume estimate (Glass transcripts carry no token counts and redact assistant prose). - When the classic IDE's extension host is running it already credits prompts, so the CLI detects its listener file (live pid) and stands down - no double credit.
- Duplicate stop events for the same generation are collapsed with an atomic
once-lock in
~/.promptai/locks/. - On remote/SSH workspaces (
CURSOR_CODE_REMOTE), the remote host has no display: no ad tabs open there. Bank credits withpromptai watchfrom any browser (/watch?device=<your device id>) instead.
State lives in ~/.promptai/ (config.json, state.json, cli.log).
Setup
npm install -g @promptai.credit/cli
promptai install claude # Claude Code hooks
promptai install cursor # Cursor Agents Window / classic IDE hooks
# then:
promptai status # device, balance, banked ad watches, recent prompts
promptai watch # open a rewarded ad now (banks a credit for later)
promptai set wallet 0x... # payout address
promptai claim # USDC on Base
promptai set ads off # opt out any timeThe default server is https://api.promptai.credit; point elsewhere with
promptai set server <url>.
Developing from the repo instead: pnpm --filter @promptai.credit/cli build, then
node product/cli/dist/index.js install claude (hooks embed the absolute path).
Notes
- Credits only accrue for turns funded by a verified ad watch, enforced server-side (same rules as the Cursor extension: one session funds one prompt, capped at $5).
- Headless environments (CI, ssh without a display) never get browser tabs and simply skip crediting.
- Uninstall with
promptai uninstall claude; other hooks in your settings are preserved.
