openai-codex
Python SDK for Codex
What it is and what it does
OpenAI Codex Python SDK is a client library for building applications that interact with Codex, OpenAI's code generation and understanding model. It provides a context-managed interface to start threads, execute turns (prompts), and retrieve results including final responses and token usage. The SDK handles authentication automatically when credentials are already available, and supports explicit login flows via ChatGPT browser login, device-code flow, or API key.
The package is designed for developers building AI-assisted tools and agents that need to run Codex operations programmatically. It depends on pydantic for data validation and openai-codex-cli-bin for underlying binary support. The SDK is actively maintained, recently released, and carries no known vulnerabilities.
Use it for:
- Build an automated code review tool that uses Codex to analyze and explain repository structure and code patterns.
- Create an AI agent that generates or refactors code by running Codex turns in response to user prompts.
- Integrate Codex into a development IDE or editor plugin to provide inline code explanations and suggestions.
- Batch-process multiple code repositories to extract summaries, documentation, or architectural insights.
- Implement multi-turn conversations with Codex where each turn builds on previous context and results.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python SDK for building applications that interact with OpenAI Codex, enabling thread creation, turn execution, streaming, and workspace access control through a context-managed interface.
Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and is licensed permissively under Apache-2.0. Install it if you need to programmatically interact with OpenAI Codex from Python; the context-managed API and built-in authentication handling make it straightforward to integrate into applications.
Install
openai-codex on PyPI
pip
pip install openai-codexuv
uv add openai-codexpoetry
poetry add openai-codexInstalling openai-codex
Before you install
Low install friction with only two runtime dependencies (pydantic and openai-codex-cli-bin). Active maintenance with a recent release 28 days ago and ongoing repository activity.
License in practice
Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely as long as you include the license notice.
Quickstart
pip install openai-codex
from openai_codex import Codex
with Codex() as codex:
thread = codex.thread_start()
result = thread.run("Explain this repository in three bullets.")
print(result.final_response)
Requires Python 3.10 or later; existing Codex authentication must be available or you must authenticate via ChatGPT login, device code, or API key before running turns.
Verify before relying
- Whether openai-codex-cli-bin is a system binary dependency or a Python package that must be installed separately.
- What 'workspace access control' concretely enables—whether it restricts file/directory scope, user permissions, or something else.
- Whether the SDK supports streaming responses in real time or only returns final results.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — pydantic, openai-codex-cli-bin |
| Maintenance | actively maintained — 28 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 236,449/month — #8,984 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: openai_codex-0.144.4-py3-none-any.whl
Keywords: codex, sdk, llm, ai, agents
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
openai-codex-cli-binProvides a local command-line interface to…
permissive · top 15,000 on PyPI
openhands-workspaceProvides Python and REST APIs for building…
unclear · top 15,000 on PyPI
openai-agentsA framework for building multi-agent LLM…
permissive · top 1,000 on PyPI
openhands-sdkOpenHands SDK provides Python and REST APIs for…
unclear · top 5,000 on PyPI
openhands-toolsProvides Python and REST APIs for building AI…
unclear · top 5,000 on PyPI
opentelemetry-instrumentation-openai-agentsAdds distributed tracing to OpenAI Agents…
permissive · top 5,000 on PyPI
portkey-aiPortkey is a Python SDK that wraps…
permissive · top 5,000 on PyPI
llama-index-llms-openaiIntegrates OpenAI's language models into…
permissive · top 1,000 on PyPI
composio-openai-agentsBridges Composio's tool catalog to OpenAI's…
permissive · top 15,000 on PyPI
langgraph-sdkPython SDK for building and deploying agentic…
permissive · top 1,000 on PyPI