Skip to main content

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

CC0 1.0 Universal.

Metadata

Release files for codexcw 0.5.1

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

Source distribution (sdist)

Source distribution for codexcw 0.5.1
File Size Uploaded
codexcw-0.5.1.tar.gz 77.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for codexcw 0.5.1
File
codexcw-0.5.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
codexcw-0.5.1-cp39-abi3-musllinux_1_1_x86_64.whl CPython 3.9 abi3 Linux musl 1.1+ x86-64 Details
codexcw-0.5.1-cp39-abi3-musllinux_1_1_aarch64.whl CPython 3.9 abi3 Linux musl 1.1+ ARM64 Details
codexcw-0.5.1-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.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
codexcw-0.5.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
codexcw-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 6.5 MB

Release files / codexcw-0.5.1.tar.gz

Download URL codexcw-0.5.1.tar.gz
Size 77.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e9f58988e729063ffa2b4f76d08e739fd8cc6a9196e9b7d6e86b1fde6b6e085c
BLAKE2b-256 checksum
How to use checksums
4971a84d8e010b49f0b1be175f2754f26c72754c8dabf668b3b6a134fb5d6def
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 31, 2026.

Transparency log

Release files / codexcw-0.5.1-cp39-abi3-win_amd64.whl

Download URL codexcw-0.5.1-cp39-abi3-win_amd64.whl
Size 870.2 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
fed4d33a7c86619b25ad7612b915736490479e5f01584c9d16fa208f69e6d528
BLAKE2b-256 checksum
How to use checksums
ce4e6c3fb942f83cc25baefb323072e08bf117e3e4c602961ed912b5abc2fffc
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 31, 2026.

Transparency log

Release files / codexcw-0.5.1-cp39-abi3-musllinux_1_1_x86_64.whl

Download URL codexcw-0.5.1-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
8c3f855af262427ce3a8347796bfdd50cb757ff4e3b280d053ced70a41290798
BLAKE2b-256 checksum
How to use checksums
12132ed93180fd3aa1dc3faebe8c6e4f287faad747aaa7d0c89010f9441d99a5
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 31, 2026.

Transparency log

Release files / codexcw-0.5.1-cp39-abi3-musllinux_1_1_aarch64.whl

Download URL codexcw-0.5.1-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
68f3b777890f7b36d29b4c82b4754b52a6f161327255e7a2f83420dbcb22597f
BLAKE2b-256 checksum
How to use checksums
cd25906fb1a70d89b65ac1eeed297b757992a28bd1fb4072dfebb28aaaa09971
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 31, 2026.

Transparency log

Release files / codexcw-0.5.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL codexcw-0.5.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 892.9 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8c6a7b00598196d22179c2f590472f5ce771f4f618ab24ede17de9eab0f7da49
BLAKE2b-256 checksum
How to use checksums
ead458f50cb8e93049d42aa1a53fdb653d8efa00861ee4f7eaf419f8b8b4a440
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 31, 2026.

Transparency log

Release files / codexcw-0.5.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL codexcw-0.5.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 854.7 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
a3d19a469d9e6566586cfd026bdbf70cbceb596e0d2e1f3514f30d114d033f19
BLAKE2b-256 checksum
How to use checksums
6d8e7aadea0f034ee663abd1d5ec8d511bbb5b28ae50072c08a03ea204a21eec
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 31, 2026.

Transparency log

Release files / codexcw-0.5.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL codexcw-0.5.1-cp39-abi3-macosx_11_0_arm64.whl
Size 817.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
60aa66276162612cf8da1af67279588733307faa626bd0d0b4ebb08b379c4ae9
BLAKE2b-256 checksum
How to use checksums
051123499691beab81ef933ab34febf424c28cdaff1388e38bb9bb49e2cc60d2
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 31, 2026.

Transparency log

Release files / codexcw-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL codexcw-0.5.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 858.7 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4c9005f194c83f809253491eac73f9e9de2efa348dc569ef8d296b5022820029
BLAKE2b-256 checksum
How to use checksums
37e6eb91df606869ca62abab2954bbba1181cd05c8281bf33968998b1ad7301a
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 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

8 release files

0.5.0

8 release files

0.4.1

8 release files

0.4.0

8 release files

0.3.0

8 release files

0.2.3

8 release files

0.2.2

8 release files

0.2.1

8 release files

0.2.0

8 release files

0.1.0

8 release files

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