Headless Python SDK
Typed sync and async interfaces for the
headless command-line tool.
The CLI remains the execution engine and the authority for option validation.
Requirements
- Python 3.10 or newer
- Node.js 22 or newer
- A
headlessexecutable onPATH
You can select a different executable with binary=...,
HEADLESS_CLI_BIN, or HEADLESS_BIN, in that order.
Usage
from headless_cli import Headless
headless = Headless()
result = headless.run(
"codex",
prompt="Review this repository",
model="gpt-5",
fast=True,
reasoning_effort="high",
allow="read-only",
)
print(result.final_message)
headless.sessions.send("bughunt", prompt="Continue the fix")
headless.sessions.launch("review", "codex", prompt="Review the repository")
headless.runs.message("auth", "worker-1", prompt="Fix tests", background=True)
headless.cron.pause("inbox-triage")
headless.docker.doctor()
The high-level read and run methods use Headless' versioned SDK protocol.
stream() yields parsed SdkTrace, SdkResult, and SdkError envelopes.
Prompts use stdin wherever the CLI permits, keeping them out of process
argument lists.
Protocol compatibility is checked on the first structured operation and
cached for the client lifetime. If the installed CLI is too old, the SDK
raises HeadlessVersionError with an upgrade command. Constructing a client
never starts a subprocess.
run(..., fast=False) and cron.add(..., fast=False) default to standard mode. Pass
fast=True to forward Headless' --fast flag for Codex or Claude; the CLI rejects it
for other agents.
Structured methods raise on SDK error envelopes by default. Pass
check=False to receive a typed SdkError value instead.
for event in headless.stream(["codex"], input="Review this diff"):
print(event)
Use invoke() as the raw escape hatch for new or uncommon CLI features:
command = headless.invoke(["--help"])
print(command.stdout)
Runs using legacy raw-output or interactive flags (json, debug, tmux,
or print_command) return sdk=None. Read their raw output through
stdout; final_message is intentionally empty because those modes do not
provide a normalized final-message result.
Interactive attach inherits the current terminal:
headless.sessions.attach("bughunt")
sessions.launch(name, ...) creates a managed tmux session using
--tmux --name. Native durable agent sessions remain available through
run(..., session=name).
Async methods have the same shape:
from headless_cli import AsyncHeadless
headless = AsyncHeadless()
result = await headless.run("claude", prompt="Fix the failing tests")
The package has no runtime Python dependencies.
Release files for headless-cli 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| headless_cli-0.6.1.tar.gz | 28.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| headless_cli-0.6.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 59.7 kB
Release files / headless_cli-0.6.1.tar.gz
| Download URL | headless_cli-0.6.1.tar.gz |
|---|---|
| Size | 28.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84a832f0901e1fd04bc733352151775d55c83d81683a1d7c135cb399024c9245
|
|
BLAKE2b-256 checksum How to use checksums |
0f307a0bb2a5a63d685a8110a2370258af3446715f3b44a79f9923944239dec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / headless_cli-0.6.1-py3-none-any.whl
| Download URL | headless_cli-0.6.1-py3-none-any.whl |
|---|---|
| Size | 30.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a40621af9b708472eee9b5fdb6ad78b5abf43f665c105678c52d9fcb63a1970f
|
|
BLAKE2b-256 checksum How to use checksums |
98b82de47dd7cbe57b33a699f672d2d5c67bd1aefbcb884c17bfa833d12dac64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency log