Skip to main content

grokbuildstreaming

Stream text from the Grok Build CLI. This library is a text-completion alternative to agentmake: you pass chat messages, and it yields response text as the CLI produces it.

Authentication is the subscription session from grok login (~/.grok/auth.json). The child process does not receive XAI_API_KEY. No API key is read or sent.

Install

pip install grokbuildstreaming

Published on PyPI. Requires the grok executable on PATH or at ~/.grok/bin/grok, and a completed grok login.

Stream

import asyncio
from grokbuildstreaming import stream_text

async def main():
    messages = [
        {"role": "system", "content": "You are a concise Bible study assistant."},
        {"role": "user", "content": "What is John 3:16 about?"},
        {"role": "assistant", "content": "It states God's love for the world."},
    ]
    async for chunk in stream_text(messages, follow_up="Quote it briefly.", model="grok-4.7"):
        print(chunk, end="", flush=True)

asyncio.run(main())

messages use role and content, the same shape agentmake accepts. follow_up is the newest user turn. An explicit system argument is sent with --system-prompt-override. System messages already in messages stay in the user prompt, so a generic identity does not outrank that task. Each call is a new headless process: the library does not resume a previous Grok session.

The process is text-only. It runs with --max-turns 1, plan mode off, web search off, subagents off, and built-in tools removed, in a temporary working directory. Cancel an in-flight stream by setting the asyncio.Event passed as cancel_event.

collect_text returns the whole reply:

from grokbuildstreaming import collect_text

text = await collect_text(follow_up="Reply with exactly: pong")

Metadata

Release files for grokbuildstreaming 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grokbuildstreaming 0.1.3
File Size Uploaded Provenance
grokbuildstreaming-0.1.3.tar.gz 7.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for grokbuildstreaming 0.1.3
File Interpreter ABI Platform
grokbuildstreaming-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / grokbuildstreaming-0.1.3.tar.gz

Download URL grokbuildstreaming-0.1.3.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
aaea0a7f5f347d2aab8884f26dd2ec39a41a89377cd78ec19331cc020a496bb4
BLAKE2b-256 checksum
How to use checksums
e951bf2762bb3d82e6f1f2c337535f3c1bfe30e096aa97231b1c52be3799bb6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / grokbuildstreaming-0.1.3-py3-none-any.whl

Download URL grokbuildstreaming-0.1.3-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36021b864e0680106f8b2be6e6ea40cd0eabc1be525455bb94107bf0538ceadd
BLAKE2b-256 checksum
How to use checksums
d26e4135a9ee55da146cdaf62032ec945064ff1f5248b3c462e805c4d91d9575
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for grokbuildstreaming 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page