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 -e /path/to/grokbuildstreaming

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. System text is sent with --system-prompt-override. 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.0

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.0
File Size Uploaded Provenance
grokbuildstreaming-0.1.0.tar.gz 7.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 13.8 kB

Release files / grokbuildstreaming-0.1.0.tar.gz

Download URL grokbuildstreaming-0.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9c5e449c65d8c8dd2872c8dc10290a5fcfb9e969688a5f6c0ff50175fd4ad6c3
BLAKE2b-256 checksum
How to use checksums
a27560049c02ea09132f36c359862c42a6e640c756a48b48c8e8d323f27dee61
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.0-py3-none-any.whl

Download URL grokbuildstreaming-0.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc0f5431c4d0dee5780bf293411164bf9bfc2f99a07a362c8488795e700e40ec
BLAKE2b-256 checksum
How to use checksums
574dc836ce8d351fe0bd44b6a63e02656df47c18ebc294e0375ad81afaa1b0aa
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.0

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