Grokly (CLI) — best use
Grokly is a lightweight CLI for xAI’s Responses API. Use it for single-turn prompts, stateful follow‑ups (via previous_response_id), streaming output, and local job files for manual polling. It intentionally avoids deprecated Chat Completions.
Golden path
- Ensure
XAI_API_KEYis set (never pass keys via flags). - Build the CLI if needed:
pnpm build. - Use
respondfor one‑offs,chatfor follow‑ups, and--streamfor long responses. - Use
--job <path>to write a local job file if you need polling. - Keep prompts precise; avoid sharing secrets in messages or files.
Commands (preferred)
-
Single‑turn:
node dist/cli.js respond -m <model> -p "<prompt>"
-
Multi‑turn (stateful):
node dist/cli.js chat -m <model> --session .grokly-session -p "<prompt>"- Follow‑up reuses the session file.
-
Streaming:
node dist/cli.js respond -m <model> --stream -p "<prompt>"
-
Local polling (job file):
node dist/cli.js respond -m <model> --job ./jobs/run1.json -p "<prompt>"node dist/cli.js job status ./jobs/run1.jsonnode dist/cli.js job result ./jobs/run1.json
-
Retrieve/delete by response id:
node dist/cli.js response get <responseId>node dist/cli.js response delete <responseId>
Tools + allowlist
- Use
--tools web,x,codeto enable tools. - Use
--allowto restrict sources (domains for web,@handlesfor X). - Limits (xAI): web allowlist max 5 domains; X allowlist max 10 handles.
--capabilities image,videoenables media understanding (video only works withx).
Configuration
Single config name: grokly.config.json.
Search order:
- current working directory
~/.config/grokly/
Example:
{
"apiKey": "...",
"model": "grok-4-1-fast-reasoning",
"timeoutMs": 90000,
"toolChoice": "auto",
"tools": ["web", "x"],
"allow": ["docs.example.com", "@example"],
"capabilities": ["image"]
}
Safety
- Never pass secrets via flags; use env/config.
- Don’t attach
.envor credential files to prompts. - Keep file scopes tight if you’re summarizing code or docs.
Notes
- Responses API supports stateful chat via
previous_response_idbut does not support server‑side polling. - Job files are a local polling mechanism; they are not detached background jobs.
