codexcw (Python)
Run Codex, Claude Code, or Grok Build non-interactively from Python, backed by
a Rust core. Codex wraps codex exec --json; Claude wraps
claude -p --output-format stream-json; Grok uses --no-auto-update and
streaming-messages-json. All expose iterables, callbacks, results, typed
usage, and typed errors through the same API.
The selected agent executable must be on PATH and authenticated. Codex must
support codex exec --json; Claude must support --output-format stream-json;
Grok must support streaming-messages-json.
Codex defaults are automation-friendly: ephemeral sessions, non-interactive
execution, a read-only sandbox, and approval never.
The Claude agent is selected with Runner(agent=codexcw.AGENT_CLAUDE); its
events are normalized into the same event model, with model selection via the
haiku/sonnet/opus aliases (CLAUDE_MODEL_*).
Select Grok with Runner(agent=codexcw.AGENT_GROK). New runs use read-only
sandboxing and dontAsk permissions; Grok sessions are always persisted.
Install
pip install codexcw
Usage
from codexcw import Runner, Request
runner = Runner()
result = runner.run(Request(prompt="diga oi"))
print(result.final_message)
print(result.usage.total_tokens)
print(result.usage.total_cost_usd)
Streaming
from codexcw import Runner, Request
runner = Runner()
session = runner.start(Request(prompt="resuma este repo"))
for event in session.events():
if event.type == "item.completed" and event.item.type == "agent_message":
print(event.item.text)
result = session.wait()
Account usage
from codexcw import AccountUsageRequest, get_account_usage
usage = get_account_usage(AccountUsageRequest(env={"CODEX_HOME": "/tmp/codex-home"}))
print(usage.rate_limits.primary.used_percent if usage.rate_limits.primary else None)
print(usage.token_usage.summary.lifetime_tokens if usage.token_usage else None)
from codexcw import get_claude_account_usage
claude_usage = get_claude_account_usage()
print(claude_usage.windows)
Running many agent instances
from codexcw import Runner, Request
runner = Runner()
group = runner.run_many(
[Request(prompt="review package A"), Request(prompt="review package B")],
max_concurrent=2,
)
for run_event in group.events():
print(run_event.index, run_event.event.type)
results = group.wait()
Async
import asyncio
from codexcw import Request
from codexcw.aio import Runner
async def main():
runner = Runner()
session = await runner.start(Request(prompt="oi"))
async for event in session.events():
print(event.type)
result = await session.wait()
print(result.final_message)
asyncio.run(main())
License
Metadata
Release files for codexcw 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codexcw-0.5.0.tar.gz | 78.1 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| codexcw-0.5.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| codexcw-0.5.0-cp39-abi3-musllinux_1_1_x86_64.whl | CPython 3.9 | abi3 | Linux musl 1.1+ x86-64 | Details |
| codexcw-0.5.0-cp39-abi3-musllinux_1_1_aarch64.whl | CPython 3.9 | abi3 | Linux musl 1.1+ ARM64 | Details |
| codexcw-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| codexcw-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| codexcw-0.5.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| codexcw-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 6.4 MB
Release files / codexcw-0.5.0.tar.gz
| Download URL | codexcw-0.5.0.tar.gz |
|---|---|
| Size | 78.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c88fd015927575fe645270b9769c1d09f421a5ff6cd81b4ef63deb1cdb30ed8b
|
|
BLAKE2b-256 checksum How to use checksums |
8de0278237022fc9d7b403bab0f1ec9225550df8f6a54bfedef04a04acf7a944
|
| 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 28, 2026.
Transparency logRelease files / codexcw-0.5.0-cp39-abi3-win_amd64.whl
| Download URL | codexcw-0.5.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 869.0 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
77831742e6207cd19095eba82c1b8e3c40e436aa29b0892f5cd2225a5ced3d65
|
|
BLAKE2b-256 checksum How to use checksums |
837a6de09bc45e9e20bef4efcad26d7215bda8f398639aa27fee146160783492
|
| 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 28, 2026.
Transparency logRelease files / codexcw-0.5.0-cp39-abi3-musllinux_1_1_x86_64.whl
| Download URL | codexcw-0.5.0-cp39-abi3-musllinux_1_1_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux musl 1.1+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
64cbec538fa2d577a92f87f30e7b5c5f6a86625d8208a7cc44e1a85d012dd389
|
|
BLAKE2b-256 checksum How to use checksums |
381224a5e9bbea47e5afba44264b9d066fde67de858e7665c4119e8c396f29c3
|
| 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 28, 2026.
Transparency logRelease files / codexcw-0.5.0-cp39-abi3-musllinux_1_1_aarch64.whl
| Download URL | codexcw-0.5.0-cp39-abi3-musllinux_1_1_aarch64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.9 Linux musl 1.1+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
06137ce124032e2cd8ccb15244d76ef29660910d91f08dc31674dbca708cd027
|
|
BLAKE2b-256 checksum How to use checksums |
1bd4b3c8aa162761cbb9b7f70cf058a636337f7e850f862dcca56b67ae8834c2
|
| 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 28, 2026.
Transparency logRelease files / codexcw-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | codexcw-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 882.6 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3e2c84b9681980c7bf26ce93142aed3498eadde9b7a3c4f898a5c9249953b625
|
|
BLAKE2b-256 checksum How to use checksums |
482f4e99759ce2b0ab6da598a9897732691f986f5fd5d162347d8f5215faf6c0
|
| 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 28, 2026.
Transparency logRelease files / codexcw-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | codexcw-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 840.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a478e519ac1f784e29afc9751562f65cf0a4eb0154500b5731fe431b0c6f2183
|
|
BLAKE2b-256 checksum How to use checksums |
b3c5c117b6f293fbdb945362f2ec4868964077fa2bd64151364fc7a397aa145c
|
| 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 28, 2026.
Transparency logRelease files / codexcw-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | codexcw-0.5.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 804.3 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2beeb3b24eb688f9cf804a3a9a5cdda256cc8e9e41d85013f2615815cd223f5c
|
|
BLAKE2b-256 checksum How to use checksums |
abcd6b327287885369dd98b7fd38ee42357d2f702e6e6887fe3607feb948e718
|
| 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 28, 2026.
Transparency logRelease files / codexcw-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | codexcw-0.5.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 845.9 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3177334a7497d9a5a0b1024e6c2e4cbf1d6ebaa90704d23bd8dcf49784c2b195
|
|
BLAKE2b-256 checksum How to use checksums |
ae8426b62c06a273def475bd20e7be2446c7f2dd2463b69c40d613f36d7c82f4
|
| 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 28, 2026.
Transparency log