Run Codex or Claude Code non-interactively from Python, backed by a Rust core.
Project description
codexcw (Python)
Run Codex or Claude Code non-interactively from Python, backed by a Rust core.
The Codex agent wraps codex exec --json; the Claude agent wraps
claude -p --output-format stream-json. Both 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.
Defaults are automation-friendly: ephemeral sessions and non-interactive
execution, with Codex using 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_*).
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codexcw-0.4.0.tar.gz.
File metadata
- Download URL: codexcw-0.4.0.tar.gz
- Upload date:
- Size: 72.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71f6ed592c99f3c6e135f8b1446f8ad34277199f197787acf0835f1a459535bd
|
|
| MD5 |
24589c15db072e0b70aafeed42f3f5cc
|
|
| BLAKE2b-256 |
d528004bd09d06080fc40d284714c2f71836647643e4df0a376f34cc2b903946
|
Provenance
The following attestation bundles were made for codexcw-0.4.0.tar.gz:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0.tar.gz -
Subject digest:
71f6ed592c99f3c6e135f8b1446f8ad34277199f197787acf0835f1a459535bd - Sigstore transparency entry: 2188202035
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcw-0.4.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: codexcw-0.4.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 857.6 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2d507a9c3d026b8340c9e92d2b7f5675763ab264a66c030f5b170bfeb2d4ee5
|
|
| MD5 |
e99225eb489d2c6ccff457ed0d2af6f5
|
|
| BLAKE2b-256 |
41ad7a996f88cbf01ad137964814493605d64c4cdf9158282287bc10d0657ffd
|
Provenance
The following attestation bundles were made for codexcw-0.4.0-cp39-abi3-win_amd64.whl:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0-cp39-abi3-win_amd64.whl -
Subject digest:
d2d507a9c3d026b8340c9e92d2b7f5675763ab264a66c030f5b170bfeb2d4ee5 - Sigstore transparency entry: 2188202045
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcw-0.4.0-cp39-abi3-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: codexcw-0.4.0-cp39-abi3-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c237aa5fe3f4a89bff018546828fc41f61c03a9d543c398f449e7d273cf97f6
|
|
| MD5 |
ea0f3750574e36ade161ed9ad2124b8f
|
|
| BLAKE2b-256 |
1be3ce8f1d759aa79336de268aa1d8402aca009a459faa30e081566ff089fc5c
|
Provenance
The following attestation bundles were made for codexcw-0.4.0-cp39-abi3-musllinux_1_1_x86_64.whl:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0-cp39-abi3-musllinux_1_1_x86_64.whl -
Subject digest:
9c237aa5fe3f4a89bff018546828fc41f61c03a9d543c398f449e7d273cf97f6 - Sigstore transparency entry: 2188202065
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcw-0.4.0-cp39-abi3-musllinux_1_1_aarch64.whl.
File metadata
- Download URL: codexcw-0.4.0-cp39-abi3-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9+, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58d6d19ec779a15cea000ec9e1d88a009257ea11deaf2fb9d9666e3bc050bd54
|
|
| MD5 |
888497c0ceb6227b51b03cd01feed6c3
|
|
| BLAKE2b-256 |
70bc75b34c5d96ca154879ca6ccf79e6f3526eb4d7ab66874faeb982900f9258
|
Provenance
The following attestation bundles were made for codexcw-0.4.0-cp39-abi3-musllinux_1_1_aarch64.whl:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0-cp39-abi3-musllinux_1_1_aarch64.whl -
Subject digest:
58d6d19ec779a15cea000ec9e1d88a009257ea11deaf2fb9d9666e3bc050bd54 - Sigstore transparency entry: 2188202054
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcw-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: codexcw-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 872.7 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc02fe553fbf086969d57de456c32a7c8332527f58f7394e2cab7b29814dbbe7
|
|
| MD5 |
d4f230c1cc6a86f1c8743366ca543a31
|
|
| BLAKE2b-256 |
04bc8f8545fcba9b77d81e44507058db5a288d156214ade27c9d0431d406e29d
|
Provenance
The following attestation bundles were made for codexcw-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
fc02fe553fbf086969d57de456c32a7c8332527f58f7394e2cab7b29814dbbe7 - Sigstore transparency entry: 2188202048
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcw-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: codexcw-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 834.3 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b63cfc169825dc456a6cbb7bda8ff95814297be144351fd175e8d0a66707f79
|
|
| MD5 |
0cb2f72e6f112d1f4bb8d5f454490481
|
|
| BLAKE2b-256 |
881d58230d11ad8bd803ad46b678d681ac70034281024c9b5d722b3e7e2e2630
|
Provenance
The following attestation bundles were made for codexcw-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
4b63cfc169825dc456a6cbb7bda8ff95814297be144351fd175e8d0a66707f79 - Sigstore transparency entry: 2188202062
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcw-0.4.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: codexcw-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 792.2 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17445c5390227d74c62b8f34cc943ba921094d71bb0d89a300a7f53af30f3b60
|
|
| MD5 |
dd17cc6da80f2a0bddf4f59083e78750
|
|
| BLAKE2b-256 |
5284e7b7bcc276790e289e9bb8c9e1d0973f338d026bcaae60a6a2d626471dbb
|
Provenance
The following attestation bundles were made for codexcw-0.4.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
17445c5390227d74c62b8f34cc943ba921094d71bb0d89a300a7f53af30f3b60 - Sigstore transparency entry: 2188202057
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codexcw-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: codexcw-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 834.3 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8c62abc894d97cabc3f57e8b45ee5939fbb2d3aafb77d8ff97fe52bbdcec89e
|
|
| MD5 |
2c16d8b7b7317ac8c527c226e1f3a235
|
|
| BLAKE2b-256 |
35d66ae47bdd5077625474a3d1c49ee7f749a23fb42eb2b83f8100564e8f3746
|
Provenance
The following attestation bundles were made for codexcw-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release-pypi.yml on c3-oss/codexcw
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codexcw-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
d8c62abc894d97cabc3f57e8b45ee5939fbb2d3aafb77d8ff97fe52bbdcec89e - Sigstore transparency entry: 2188202042
- Sigstore integration time:
-
Permalink:
c3-oss/codexcw@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Branch / Tag:
refs/tags/py-v0.4.0 - Owner: https://github.com/c3-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-pypi.yml@8b1f15e04e51a225877ad1713e7bc22ff92a1939 -
Trigger Event:
push
-
Statement type: