Codex

OpenAI's open-source coding agent for the terminal, which inspects code, makes changes and runs commands with OpenAI's models. Run it in EnvHaven from any browser, signed in once with your own account, and keep it working 24/7; or install it on your own machine.

Updated November 23, 2026 · Checked against Codex 0.157.1 in EnvHaven v1.9.0

At a glance
Made byOpenAI
Commandcodex
Version checked0.157.1, in EnvHaven v1.9.0
LicenseApache-2.0, source
Documentationlearn.chatgpt.com/docs/codex/cli

Use Codex in EnvHaven

  1. Open your workspace in any browser, on a laptop, a tablet or a phone.
  2. Tap Launch, choose Codex and tap Sign in: it runs codex login --device-auth, which shows a one-time code to approve in ChatGPT (turn on device code sign-in in ChatGPT’s security settings first).
  3. Start it with one tap: signed in, Codex gets a green dot in the Launch menu and an icon in the workspace’s top bar. Support is built in (0.157.1), so there is nothing to install or update.
  4. Give it a task. The image writes both settings into ~/.codex/config.toml, so codex starts without approvals.
  5. Close the tab whenever you like. The workspace is an always-on Linux machine, so Codex keeps working, and every device you open it from shows the same session.

Every agent signs in with your own account: EnvHaven never resells tokens or adds a markup.

Install Codex on another machine

macOS, Linux:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

npm:

npm install -g @openai/codex

Homebrew:

brew install --cask codex

Sign in from the terminal

In a workspace the Launch menu does this for you. On any other machine, or when you would rather type it:

  • Run codex login and sign in with ChatGPT. On a machine without a browser, codex login --device-auth prints a code to approve on any device (turn on device code login in ChatGPT’s security settings first).
  • Or use an API key: printenv OPENAI_API_KEY | codex login --with-api-key, or CODEX_API_KEY for non-interactive runs. Codex does not read OPENAI_API_KEY by itself.
  • ChatGPT Plus and Pro include Codex in the CLI, as do Business and Enterprise workspaces; API-key sessions bill at API rates.

Run Codex without permission prompts

For one session:

codex --dangerously-bypass-approvals-and-sandbox

As the default, in ~/.codex/config.toml:

approval_policy = "never"
sandbox_mode = "danger-full-access"

The flag turns off approvals and the sandbox together; its help calls it “EXTREMELY DANGEROUS” and meant for environments that are already sandboxed, and OpenAI’s docs recommend full access inside Docker for that reason. Quote the values in config.toml: an unquoted never fails with “Error loading config.toml”. Administrators can forbid both values through requirements.toml.

In EnvHaven: The image writes both settings into ~/.codex/config.toml, so codex starts without approvals. The details, and when full access is safe, are on the Codex full-access page.

Instructions file

Codex reads AGENTS.md, AGENTS.override.md, ~/.codex/AGENTS.md. It reads them from the project root down to the working directory, capped at 32 KiB by default; project_doc_fallback_filenames in config.toml adds other names.

Add MCP servers

codex mcp add <name> -- <command> [args...]

Use --env KEY=VALUE for stdio servers and --url <url> for streamable HTTP. Servers are saved as [mcp_servers.<name>] tables in ~/.codex/config.toml.

The MCP config converter writes the same server for every agent at once.

Run it from scripts

codex exec "<prompt>"

Headless runs cannot stop to ask, so they need the full-access setting above.

Codex away from your desk

Codex keeps working only while the machine it runs on is awake. In EnvHaven that machine is the workspace, which never sleeps: start a task, close the laptop and check on it from a phone.

OpenAI’s own options:

  • The ChatGPT mobile app starts, steers and approves Codex tasks in the cloud or on a computer running the ChatGPT desktop app; it is set up from the desktop app.
  • codex cloud starts and lists cloud tasks from the terminal.

Compare Codex

When Codex misbehaves