Skip to main content

Python SDK for Codex CLI with bundled platform binaries

Reason this release was yanked:

mistake

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
  • ThreadOptions: model, sandbox_mode, working_directory, skip_git_repo_check
  • TurnOptions: output_schema

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codex_python-1.0.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

codex_python-1.0.0-cp314-cp314t-win_arm64.whl (26.7 MB view details)

Uploaded CPython 3.14tWindows ARM64

codex_python-1.0.0-cp313-cp313t-win_arm64.whl (26.7 MB view details)

Uploaded CPython 3.13tWindows ARM64

codex_python-1.0.0-cp312-abi3-win_arm64.whl (26.7 MB view details)

Uploaded CPython 3.12+Windows ARM64

codex_python-1.0.0-cp312-abi3-win_amd64.whl (29.3 MB view details)

Uploaded CPython 3.12+Windows x86-64

codex_python-1.0.0-cp312-abi3-musllinux_1_2_x86_64.whl (30.4 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ x86-64

codex_python-1.0.0-cp312-abi3-musllinux_1_2_aarch64.whl (28.2 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

codex_python-1.0.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (30.1 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

codex_python-1.0.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (28.1 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

codex_python-1.0.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (51.2 MB view details)

Uploaded CPython 3.12+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file codex_python-1.0.0.tar.gz.

File metadata

  • Download URL: codex_python-1.0.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for codex_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1efe6b941b4b30d791ca12bd1793f710287cf6af19c8e28424de6b647ea5023f
MD5 7baf39b75640ec7eb0121c754586c887
BLAKE2b-256 c22aa0ff1d3cfc8094150b7de423da622d6da4eb88fa879e4d19ef31ddcee35b

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0.tar.gz:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp314-cp314t-win_arm64.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp314-cp314t-win_arm64.whl
Algorithm Hash digest
SHA256 660335cf0cb40fbb11e94cec2a84974a3e865920fc5bf648191506fe81febbfa
MD5 ab61216eed958f93228c3034af889b37
BLAKE2b-256 ad578d7bbe817b2b4f8034913992034c055e872cfca33504c9024a9bd61c225a

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp314-cp314t-win_arm64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp313-cp313t-win_arm64.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp313-cp313t-win_arm64.whl
Algorithm Hash digest
SHA256 970b60812f5436b7ccc63c124d452aa873d1c1defcc5ecbc1f915c67299ab714
MD5 b998ce46c7efb012e93f31e63f8b277c
BLAKE2b-256 ad20377241412287d155841b394e5120116c14bafd73c889fb7fa703969d82f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp313-cp313t-win_arm64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp312-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp312-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 4fdde57f13b90efb971967d497bc0d290e647ad87ddb353582bbe4f674e86475
MD5 7ef785a36cabdb94d8e7458a0e132e19
BLAKE2b-256 0082a6216acb174aea0a825d43801ed1dd80ff55884adb8a89f8da6a797fcab4

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp312-abi3-win_arm64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: codex_python-1.0.0-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

Hashes for codex_python-1.0.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 67286b75006fd17669b1efaadc68516b9a077c9eb0d582a787d0c088c2f4f87c
MD5 222afd77817c7d6c50b7869af45e2907
BLAKE2b-256 14d98813e6f4db0abc4921847e4129b18c47c55bf94f3589a8d1d5e8af33adcb

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp312-abi3-win_amd64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bf7440f21d555a6d7ad2d77d51826548213038e00ebf2437f070264b05a7a39d
MD5 2d5355be9e6d0f9f29b9240f0fae94e2
BLAKE2b-256 6e56e9bbc1cc8c1bb541bf7a84d85ef976a5075ec12992f3472b521919111314

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp312-abi3-musllinux_1_2_x86_64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp312-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 3faf40aeec4fbd548acf96b4b9efd520b17570b8fb6527e39204df446b2fa27c
MD5 35fccb862c6673ce355cfd6ad8f5c551
BLAKE2b-256 47c86a10b4f12fdd80443b734fe0b9cdcc4151f09cef7634f3b85d5eaf0485df

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp312-abi3-musllinux_1_2_aarch64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 549d27f6103a6cb2cab7e404f872512a4e30acf1b9c9bbc71705766041d7b517
MD5 fb442eeae8368e21de9aea7c91586f5e
BLAKE2b-256 6d2945f9169aa993d7a24649644a316ad2bf4af4a21270d19af503d30c94757d

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0c709f8f9018417f27fb100cb8cd7a8f3827d8148b3434244478384a82215b10
MD5 447043b7ccac5278a68e69caf892cb33
BLAKE2b-256 5690b9704e3fb0b5d8eb793909867096c727326b0a7b9c372af5b40a97bb4e69

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_python-1.0.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for codex_python-1.0.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 26289599dcbf16481c3c43fd34c397ddbe65e9d66a784f483b9df7c4251c9fa8
MD5 f39d96331cb6a29e81f933174472191e
BLAKE2b-256 ee805ac4d3ece444079583349f75e083f974b5be8339cf96d5a213285c43f7b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_python-1.0.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release-published.yml on gersmann/codex-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page