In short.
This E2B guide helps developers automate OpenAI Codex in a hosted sandbox, with the main catch that its examples give the agent broad permissions inside an environment with internet access enabled by default. A prebuilt template supplies Codex, and TypeScript and Python examples explain how to manage commands, files, repository changes and sessions. Pricing, pinned software versions and measured reliability are unspecified. The examples have not been executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete page at [https://docs.e2b.dev/agents/codex.md]: interactive CLI use, SDK setup, headless execution, repository editing, structured output, streaming, session resumption, image input and custom templates. It includes the page’s notices about approval bypass, default internet access, network-rule limits, separate command and sandbox timeouts, cleanup, strict schemas and argument placement. The documentation-index prompt and related links do not extend coverage. Linked pages, repositories, service terms and pricing are excluded. No commands or examples were executed; runtime behavior and security guarantees remain unassessed.
The overview
Identity
The resource is E2B’s Codex integration guide at [https://docs.e2b.dev/agents/codex.md]. It describes OpenAI Codex as an open-source coding agent and introduces E2B’s prebuilt codex template, which already has the agent installed. The guide teaches how to operate Codex through E2B’s CLI and SDKs.
Assessment
The guide offers a concrete starting point for developers building automated coding jobs around a remote environment. It connects agent execution with practical tasks such as retrieving file changes, collecting structured reports and continuing earlier work. Adoption still requires decisions about credentials, network access, sandbox lifetime and output review. Successful task completion, production reliability and isolation strength are not established by the supplied examples.
Users
The clearest audience is developers who want to run coding-agent tasks from TypeScript or Python applications. Terminal users can follow the shorter interactive CLI path. Beginners receive installation commands and complete examples, but still need familiarity with environment variables, API keys and command-line tools. Repository workflows additionally assume an understanding of git and code review.
Capabilities
Documented capabilities include interactive Codex sessions, non-interactive tasks through codex exec, cloning repositories, editing files, retrieving git diffs and reading generated files. Further examples cover JSON Schema-constrained final responses, JSONL event streams, resuming sessions and supplying screenshots or mockups as image input.
Developers can also derive a custom environment from the codex template to add dependencies or configuration. The example build requests 2 CPUs and 2048 MB of memory; these are example settings rather than stated minimum requirements.
Using it
Requirements
The SDK examples require E2B_API_KEY and CODEX_API_KEY environment variables, with the latter holding an OpenAI API key that is passed into the sandbox. Install the e2b package for the chosen language. TypeScript examples also use tsx and require an ES module project because they use top-level await.
Interactive use requires the E2B CLI. The private-repository instructions introduce a GITHUB_TOKEN, while image examples require uploading a local image file. Exact runtime versions, Codex versions, SDK versions and model requirements are unspecified.
Mechanism
The SDK creates an E2B sandbox from the codex template and invokes Codex through its command interface. Codex works on files inside that environment, and the application retrieves output through command results, callbacks or file reads. The page describes E2B as isolating this work from the host machine.
The headless examples use --dangerously-bypass-approvals-and-sandbox to automatically approve tool calls and disable Codex’s own command sandbox. E2B allows internet access by default. The page identifies allowInternetAccess and hostname or CIDR rules as controls; hostname rules cover HTTP(S) only. Credentials intentionally passed into the sandbox are available there, so host isolation alone does not protect those supplied secrets.
Setup
For interactive use, the page gives e2b sbx create codex followed by codex inside the sandbox. For TypeScript, it initializes an ES module project and installs e2b and tsx. For Python, it installs e2b with pip. SDK examples then create the sandbox and pass in CODEX_API_KEY.
TypeScript examples use a finally block to kill the sandbox, while Python examples use a context manager for cleanup. Codex commands set timeoutMs: 0 or timeout=0 to remove the SDK’s default 60-second command limit. This does not remove the separate sandbox lifetime; several examples set that lifetime to ten minutes.
Example
The repository-editing example creates a sandbox, clones the public e2b-dev/claude-code-fastapi repository into /home/user/repo and asks Codex to add error handling to API endpoints. It sets the working directory with -C, streams standard output, retrieves git diff and then cleans up the sandbox. No resulting diff or execution result is supplied.
A separate code-review example writes a JSON Schema for issues containing a file, line, severity and description, then passes its path through --output-schema. The page requires additionalProperties: false on every schema object and every property to appear in required. This constrains response structure; it does not establish whether reported issues are accurate or complete.
Assessment & evidence
Limitations
The examples were not executed. Code quality, task success rates, latency, compatibility and security guarantees are not assessed. The page provides no benchmark results or detailed retry and recovery strategy.
Streaming output can arrive in chunks that end mid-line, so consumers must buffer incomplete JSONL events. Session files are stored under ~/.codex/sessions inside the sandbox; the page demonstrates reuse in the same sandbox without establishing recovery after that sandbox is destroyed. Sandbox persistence is only a linked topic. A schema-valid response also remains subject to factual and semantic errors.
Reasoning
The documented combination of a preinstalled agent, programmable commands and retrievable changes makes this guide a plausible starting point for applications that delegate bounded repository tasks. Structured responses can help applications consume results, while event streams can expose progress. This assessment follows from the interfaces shown; it does not establish that generated edits or security findings will be correct. Broad agent permissions make network controls and review of resulting changes material adoption decisions.
Alternatives
Within the guide, interactive CLI use suits a person directing a terminal session, while TypeScript and Python SDK examples suit application-controlled jobs. The prebuilt template reduces initial environment setup; a derived template supports additional dependencies and configuration.
The page links to sandbox persistence and SSH guides without explaining their full behavior. It provides no comparison with local Codex execution or other sandbox services, so relative cost, speed and isolation are unknown.
Evidence
The source is E2B’s Codex integration guide at [https://docs.e2b.dev/agents/codex.md], which provides CLI instructions and TypeScript and Python examples.
The page supplies explanatory text and code examples. It contains no execution receipts, generated repository changes or measured results. Linked documentation and repositories are outside the available evidence, including pages covering network configuration, persistence and SSH.
Access & freshness
Costs
Total cost is unknown. The page requires E2B and OpenAI API keys but provides no service prices, included allowances, model selection, token usage or example billing totals. The custom-template CPU and memory settings do not establish a price. Sandbox cleanup and lifetime controls are documented, but their billing effects are unspecified.
Rights
The page calls Codex open-source and links to its repository at [https://github.com/openai/codex], but it does not name or reproduce a license. It also supplies no explicit license for the documentation, example snippets or template. Redistribution rights and applicable E2B and OpenAI service terms are therefore unknown from this evidence. Rights for repositories processed by the agent are not established.
Freshness
The source was captured on 2026-11-23 at 05:22:04.125 UTC. That timestamp establishes when the supplied text was captured, not when E2B published or last revised it. The page does not pin Codex, SDK or runtime versions, identify a model version or provide a template build identifier. Compatibility with later releases is unknown.
Actions
Choose the interactive CLI or an SDK example according to how the task will be controlled. Before adopting unattended execution, decide which credentials and files the sandbox needs, configure outbound network access and set a suitable sandbox lifetime. Confirm current prices, applicable terms and version compatibility.
For an initial evaluation, use a disposable repository and inspect the resulting diff. Retrieve required files before cleanup, validate structured responses and buffer streaming events by complete lines. For repository session resumption, the page places -C before the resume subcommand; it says that option is not accepted after it.
