Unofficial Python SDK for the OpenAI Codex CLI.
Project description
Unofficial Codex SDK (Python)
Unofficial, community-maintained Python SDK for the Codex CLI.
This project is not an official OpenAI SDK. It wraps the codex CLI from @openai/codex, spawning the CLI and exchanging JSONL events over stdin/stdout.
Installation
pip install codex-sdk-unofficial
Requires Python 3.10+ and a codex executable on your PATH (or pass codex_path_override).
Status
- Package name:
codex-sdk-unofficial - Import name:
codex_sdk - Current version:
0.1.1 - Stability: alpha
Quickstart
from codex_sdk import Codex, __version__
print("codex_sdk version:", __version__)
codex = Codex()
thread = codex.start_thread()
turn = thread.run("Diagnose the test failure and propose a fix")
print(turn.final_response)
print(turn.items)
Call run() repeatedly on the same Thread to continue a conversation.
next_turn = thread.run("Implement the fix")
Streaming responses
run() buffers events until completion. To react to intermediate progress, use run_streamed().
streamed = thread.run_streamed("Diagnose the test failure and propose a fix")
for event in streamed.events:
if event["type"] == "item.completed":
print("item", event["item"])
elif event["type"] == "turn.completed":
print("usage", event["usage"])
Structured output
schema = {
"type": "object",
"properties": {
"summary": {"type": "string"},
"status": {"type": "string", "enum": ["ok", "action_required"]},
},
"required": ["summary", "status"],
"additionalProperties": False,
}
turn = thread.run("Summarize repository status", {"output_schema": schema})
print(turn.final_response)
Attaching images
thread.run(
[
{"type": "text", "text": "Describe these screenshots"},
{"type": "local_image", "path": "./ui.png"},
{"type": "local_image", "path": "./diagram.jpg"},
]
)
Resuming an existing thread
thread = codex.resume_thread("thread_id_here")
thread.run("Implement the fix")
Working directory and execution options
thread = codex.start_thread(
{
"working_directory": "/path/to/project",
"skip_git_repo_check": True,
"sandbox_mode": "workspace-write",
}
)
Overriding CLI environment
codex = Codex(
{
"env": {"PATH": "/usr/local/bin"},
}
)
Global --config overrides
codex = Codex(
{
"config": {
"show_raw_agent_reasoning": True,
"sandbox_workspace_write": {"network_access": True},
}
}
)
Publish Checklist
- Update
pyproject.tomlversion andsrc/codex_sdk/__init__.py__version__. - Run tests:
PYTHONPATH=src uv run pytest -q
- Build artifacts:
uv run --with build python -m build
- Commit and create a version tag:
git add . git commit -m "release: v0.1.1" git tag -a v0.1.1 -m "v0.1.1"
- Push GitHub branch + tags:
git push origin main --tags
- Publish to PyPI (after creating a trusted publisher or API token):
uv run --with twine twine upload dist/*
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 Distribution
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_sdk_unofficial-0.1.1.tar.gz.
File metadata
- Download URL: codex_sdk_unofficial-0.1.1.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd57fee526b36628da8951f05a1d60c422143bd8cda0986633b851e82ce916a6
|
|
| MD5 |
1d2f72e3529fe9d20f88f1e831fb4b71
|
|
| BLAKE2b-256 |
b1038e48478d0e8fe6dc79a91a0af19428f33561925e659d729cd0ccad4b6061
|
Provenance
The following attestation bundles were made for codex_sdk_unofficial-0.1.1.tar.gz:
Publisher:
publish.yml on Goodbuilder34/codex-sdk-unofficial
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_sdk_unofficial-0.1.1.tar.gz -
Subject digest:
fd57fee526b36628da8951f05a1d60c422143bd8cda0986633b851e82ce916a6 - Sigstore transparency entry: 1009478801
- Sigstore integration time:
-
Permalink:
Goodbuilder34/codex-sdk-unofficial@d0bc8150461316d5b73e080b98dc63e07860ebe2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Goodbuilder34
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0bc8150461316d5b73e080b98dc63e07860ebe2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_sdk_unofficial-0.1.1-py3-none-any.whl.
File metadata
- Download URL: codex_sdk_unofficial-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84b6a300862ce2bc94aff75217d19d659f5ff0926dbf21454e3adc35a466139c
|
|
| MD5 |
11a257a08e831fdc7387a69db42da4b6
|
|
| BLAKE2b-256 |
12c2aa8f3793a3e604e2977c4ce120c9cf9bc34b4a4b9ef0e8da2f7ee3ea7a27
|
Provenance
The following attestation bundles were made for codex_sdk_unofficial-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Goodbuilder34/codex-sdk-unofficial
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_sdk_unofficial-0.1.1-py3-none-any.whl -
Subject digest:
84b6a300862ce2bc94aff75217d19d659f5ff0926dbf21454e3adc35a466139c - Sigstore transparency entry: 1009478805
- Sigstore integration time:
-
Permalink:
Goodbuilder34/codex-sdk-unofficial@d0bc8150461316d5b73e080b98dc63e07860ebe2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Goodbuilder34
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d0bc8150461316d5b73e080b98dc63e07860ebe2 -
Trigger Event:
push
-
Statement type: