OpenAI releases Python and TypeScript SDKs for Codex

New SDKs allow developers to integrate Codex programmatically into CI/CD pipelines, internal tools, and custom applications using Python 3.10+ or Node.js 18+.

cpaua2 min256
OpenAI releases Python and TypeScript SDKs for Codex

OpenAI has released Python and TypeScript SDKs for Codex, enabling developers to integrate the model programmatically into applications, internal workflows, and CI/CD pipelines. These libraries allow for the automation of coding tasks and the creation of custom agents capable of performing complex engineering work without requiring manual wrappers.

Managing threads and session state

The SDKs allow applications to start, continue, and resume local threads. Developers can identify specific integrations by setting a threadSource label during thread creation, which is preserved when a thread is resumed.

To optimize performance, the Python SDK supports resuming a thread without loading its full history by passing include_turns=False to thread_resume() or thread_fork(). The model retains the context, but the history can be retrieved separately via thread.read(include_turns=True).

When switching model providers, the codex.thread_fork(thread_id) method allows a user to continue from the same history on a new provider, provided they use Codex CLI 0.166.0 or later.

Sandbox environment and filesystem access

The SDK provides three presets for managing filesystem access within the sandbox. Sandbox.read_only allows reading files without write permissions, Sandbox.workspace_write enables writing inside the workspace and configured roots, and Sandbox.full_access removes all filesystem restrictions.

These presets can be applied during thread creation or changed for specific turns. For example, a developer can use workspace_write to make a change and then switch to read_only for a subsequent review turn.

Integration with external data and models

The Python SDK supports ExternalMessage to pass content from other agents or tools, such as an issue tracker. Codex treats this input as tool output, assigning it a lower priority than developer or user instructions.

The library supports specific models like gpt-6.1-sol for users with account access. For asynchronous applications, the AsyncCodex class is available. This programmatic control complements other Codex desktop developments by moving control to the API level.

Installation and configuration

The Python SDK requires Python 3.10 or later and is installed via:

shellscript
pip install openai-codex

The TypeScript library requires Node.js 18 or later and is installed via:

shellscript
npm install @openai/codex-sdk

Configuration can be managed through structured settings or raw TOML strings via configOverrides. Raw overrides take precedence over structured config, while managed settings like baseUrl take the highest priority.

Sources

Codex SDK | ChatGPT Learn

Share

Author

cpaua

VibeCode blog admin. Writing about vibe coding, AI and open source.

Related news

Comments

To leave a comment, log in
Loading...

Weekly digest

The best of vibe coding, AI agents and open source — once a week, no spam.