Codex Python SDK: embed Codex in your Python apps
Melvin Vivas · X post · 2026-06-03 · Open on X
Topics: AI Agents, Tool Use & MCP, AI Dev Tools & Productivity · Level: intermediate
Summary
OpenAI released a Codex Python SDK that lets developers embed the Codex coding agent in their Python apps and workflows. It supports threads, turns, streaming, session resumption, image inputs and sandbox control, and it reuses your existing Codex auth.
Key points
- The Codex Python SDK embeds the Codex agent directly into Python apps and workflows.
- Start threads and run turns programmatically.
- Stream progress events while the agent works.
- Resume previous sessions.
- Pass images as input.
- Control sandbox access for safety, and reuse your existing Codex authentication; install it with pip.
Resources mentioned
- Codex Python SDK · tool · github.com · free
OpenAI's Python SDK for running Codex agent threads, turns and sessions from your own code. - OpenAI Codex · tool · openai.com · paid
OpenAI's coding agent. In the diagram it writes code, fixes review findings and drives the build loop. The creator also used it to make this video.
Also in: An agent bot that installs and drives Codex on its own (Melvin Vivas on X · notes), Asking a Coder bot to install Codex (Melvin Vivas on X · notes), Sign in with ChatGPT: Setting Usage Limits for Each App (Melvin Vivas on X · notes), Codex Cloud Environments Must Be Saved & Published Before Use (Melvin Vivas on X · notes) and 240 more
Try this
- Install the Codex Python SDK with pip and try starting a thread and streaming its progress.
- Build a Python automation that runs Codex in a sandbox to fix code or generate patches inside your workflow.
More in AI Agents, Tool Use & MCP
- Building a basic MCP server with GLM 5.2 in Claude Code
- Testing free GLM 5.2 in Devin Desktop to create an MCP server
- Sakana Fugu: Multi-Agent Orchestration Behind a Single Model API
- Dynamic workflows: Claude Code running hundreds of parallel subagents
- Cursor's /orchestrate Skill: Agents That Spawn Agents via the Cursor SDK
- Gemma 4 E4B Driving an iOS Simulator With Argent