Python SDK for Codex CLI with bundled platform binaries
Project description
codex-python
Python SDK for Codex with bundled codex binaries inside platform wheels.
The SDK mirrors the TypeScript SDK behavior:
- Spawns
codex exec --experimental-json - Streams JSONL events
- Supports thread resume, structured output schemas, images, sandbox/model options
Install
pip install codex-python
Quickstart
from codex import Codex
client = Codex()
thread = client.start_thread()
result = thread.run("Diagnose the failing tests and propose a fix")
print(result.final_response)
print(result.items)
Streaming
from codex import Codex
client = Codex()
thread = client.start_thread()
stream = thread.run_streamed("Investigate this bug")
for event in stream.events:
if event["type"] == "item.completed":
print(event["item"])
elif event["type"] == "turn.completed":
print(event["usage"])
Structured output
from codex import Codex, TurnOptions
schema = {
"type": "object",
"properties": {"summary": {"type": "string"}},
"required": ["summary"],
"additionalProperties": False,
}
client = Codex()
thread = client.start_thread()
result = thread.run("Summarize repository status", TurnOptions(output_schema=schema))
print(result.final_response)
Input with local images
from codex import Codex
client = Codex()
thread = client.start_thread()
result = thread.run(
[
{"type": "text", "text": "Describe these screenshots"},
{"type": "local_image", "path": "./ui.png"},
{"type": "local_image", "path": "./diagram.jpg"},
]
)
Resume a thread
from codex import Codex
client = Codex()
thread = client.resume_thread("thread_123")
thread.run("Continue from previous context")
Options
CodexOptions:codex_path_override,base_url,api_key,config,envThreadOptions:model,sandbox_mode,working_directory,skip_git_repo_check,model_reasoning_effort,network_access_enabled,web_search_mode,web_search_enabled,approval_policy,additional_directoriesTurnOptions:output_schema,signal
Cancellation
import threading
from codex import Codex, TurnOptions
cancel = threading.Event()
client = Codex()
thread = client.start_thread()
stream = thread.run_streamed("Long running task", TurnOptions(signal=cancel))
cancel.set()
for event in stream.events:
print(event)
Bundled binary behavior
By default, the SDK resolves the bundled binary at:
codex/vendor/<target-triple>/codex/{codex|codex.exe}
If the bundled binary is not present (for example in a source checkout), the SDK falls back to
codex on PATH.
You can always override with CodexOptions(codex_path_override=...).
Development
make lint
make test
If you want to test vendored-binary behavior locally, fetch binaries into codex/vendor:
python scripts/fetch_codex_binary.py --target-triple x86_64-unknown-linux-musl
Project details
Release history Release notifications | RSS feed
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 codex_python-1.0.1.tar.gz.
File metadata
- Download URL: codex_python-1.0.1.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67c4cc43c3ddbac2d927e2483a78b92f79c56ecb19261e270696c28e23cebb0e
|
|
| MD5 |
e2da378dd621d48c808dea950365e78f
|
|
| BLAKE2b-256 |
c5c71faa15fad013e8089699ed2839bbb8324ebf2843f7c9447908612bb549e6
|
Provenance
The following attestation bundles were made for codex_python-1.0.1.tar.gz:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1.tar.gz -
Subject digest:
67c4cc43c3ddbac2d927e2483a78b92f79c56ecb19261e270696c28e23cebb0e - Sigstore transparency entry: 941408296
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp314-cp314t-win_arm64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp314-cp314t-win_arm64.whl
- Upload date:
- Size: 26.7 MB
- Tags: CPython 3.14t, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc6d37bce7655723edfc9c88b5e196bcfbb758329e588d9d4aaccce4e4774b31
|
|
| MD5 |
12b2d636149e42badf731928e76f8b3b
|
|
| BLAKE2b-256 |
3568db0f6c62f27db446b3f96537cbf8449aeff1bcb27403fb8e1c41be52d79c
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp314-cp314t-win_arm64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp314-cp314t-win_arm64.whl -
Subject digest:
fc6d37bce7655723edfc9c88b5e196bcfbb758329e588d9d4aaccce4e4774b31 - Sigstore transparency entry: 941408592
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp313-cp313t-win_arm64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp313-cp313t-win_arm64.whl
- Upload date:
- Size: 26.7 MB
- Tags: CPython 3.13t, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
241490e6a458e16bf89eff9dde119238625d9d95e9a1f508bae29f51cd3846e7
|
|
| MD5 |
d4065b2e2d7f8859f8b10d83537ece07
|
|
| BLAKE2b-256 |
9a6041912ea76e21ecd0d3135307737f85623d94cc25e349e3836a03f78c3016
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp313-cp313t-win_arm64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp313-cp313t-win_arm64.whl -
Subject digest:
241490e6a458e16bf89eff9dde119238625d9d95e9a1f508bae29f51cd3846e7 - Sigstore transparency entry: 941408974
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp312-abi3-win_arm64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp312-abi3-win_arm64.whl
- Upload date:
- Size: 26.7 MB
- Tags: CPython 3.12+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00d3567d616a0cb134d6fb1068bead40d204071db3549cc9280470e361328d6c
|
|
| MD5 |
f132799205ebde7b91684cca9d7659d4
|
|
| BLAKE2b-256 |
4c155d35e88170d822f489009d449a56e87853d1705771c229554ef507720871
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp312-abi3-win_arm64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp312-abi3-win_arm64.whl -
Subject digest:
00d3567d616a0cb134d6fb1068bead40d204071db3549cc9280470e361328d6c - Sigstore transparency entry: 941408912
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 29.3 MB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6770fd7b2cd70a35f583c3ea4cca6453dd9ae6b9d3c19ce92b242cfa9849f690
|
|
| MD5 |
aacafa82f5850c81743cf34efdbe98d3
|
|
| BLAKE2b-256 |
21d3c07e5be2087adf9846e35579fca8631eef02f87c380bdb3e50e63e0ac652
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp312-abi3-win_amd64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp312-abi3-win_amd64.whl -
Subject digest:
6770fd7b2cd70a35f583c3ea4cca6453dd9ae6b9d3c19ce92b242cfa9849f690 - Sigstore transparency entry: 941408421
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 30.4 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2f5245da0ca7b27ce54a3a5d688265809971b7632518c32a07b9d2d0ad62c2c
|
|
| MD5 |
c3dfd084a23562287e30b013afe67ca1
|
|
| BLAKE2b-256 |
fc725a2146cea4e3aab6ca1fdb0a95b32d9e808b81ce2213b84715e3d41e101c
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp312-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
c2f5245da0ca7b27ce54a3a5d688265809971b7632518c32a07b9d2d0ad62c2c - Sigstore transparency entry: 941408830
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 28.2 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f41b6685adc477fb344a8af86410080d45a6d4c0a518c5d33cc9b630c7815f2
|
|
| MD5 |
fd36134ffd8e539d9b63331111ac9b7f
|
|
| BLAKE2b-256 |
89779baa010284443e682275cc938fd8a79fc93d2c2269ea40d3408022b4586a
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp312-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
7f41b6685adc477fb344a8af86410080d45a6d4c0a518c5d33cc9b630c7815f2 - Sigstore transparency entry: 941408502
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 30.2 MB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b0cc6c0e32a158ad99d4a55c7bc27ea09b31662246ae6acaaf2853e23b5d8ba
|
|
| MD5 |
515f866126b1b0cd6bf9abd015cd4399
|
|
| BLAKE2b-256 |
a789e002d358119e7e25901fc4baa948321231e592b9d08fa8d2c6d81c071d00
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
0b0cc6c0e32a158ad99d4a55c7bc27ea09b31662246ae6acaaf2853e23b5d8ba - Sigstore transparency entry: 941408751
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: codex_python-1.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 28.1 MB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
905660b91f8e20ad268b7eb45edd0f025f66d4f5c66e41e1e2b5a212f3d314f9
|
|
| MD5 |
4c3891b811312151c1120e94bf61c2d6
|
|
| BLAKE2b-256 |
6e67af19fe042f41ad1b82d9ef12dd304a46d4ff16fed3b4960c29a42f690a91
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
905660b91f8e20ad268b7eb45edd0f025f66d4f5c66e41e1e2b5a212f3d314f9 - Sigstore transparency entry: 941408661
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type:
File details
Details for the file codex_python-1.0.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: codex_python-1.0.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 51.2 MB
- Tags: CPython 3.12+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d104236e9669e2ce9562b9b71492d330e68291d4e4c707e519af9bcc337c69b
|
|
| MD5 |
6cbbdcd0045764a1fd0be4d19e88a215
|
|
| BLAKE2b-256 |
935d6fc630ccdeacfacdf055f3c347969120b5ae246afcea24944b02083d67e5
|
Provenance
The following attestation bundles were made for codex_python-1.0.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release-published.yml on gersmann/codex-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_python-1.0.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
7d104236e9669e2ce9562b9b71492d330e68291d4e4c707e519af9bcc337c69b - Sigstore transparency entry: 941408363
- Sigstore integration time:
-
Permalink:
gersmann/codex-python@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/gersmann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-published.yml@58c2aba7e66b710f621970df31b0f43d7dd0384d -
Trigger Event:
release
-
Statement type: