Pi vs Codex: an open agent for any model, or OpenAI's own
Pi 1.5.2 and Codex 0.170.0 compared: licence, models and ChatGPT plans, sandbox and approvals, skills and MCP, scripted runs, and signing in on a server.
Both are free and open source, Codex under Apache-2.0 and Pi under MIT, and both can sign in with a ChatGPT account. Codex is OpenAI’s agent: built around OpenAI’s models and your ChatGPT sign-in, it runs every command inside a bubblewrap sandbox on Linux and asks before stepping outside it. Pi is a deliberately small agent that talks to 15-plus providers, never asks before it acts, and has no sandbox of its own; you add guardrails as extensions or run it in a container. Pick Codex if OpenAI’s models are what you want and you would like the guardrails already there; pick Pi if you want to move between labs’ models and shape the agent yourself. As of November 18, 2026: Codex 0.170.0, Pi 1.5.2.
Side by side
| Codex 0.170.0 | Pi 1.5.2 | |
|---|---|---|
Licence | Apache-2.0 | MIT |
Models | OpenAI by default; Ollama, LM Studio, Bedrock, Google Cloud and custom endpoints by config | “15+ providers, hundreds of models” |
How you pay | A ChatGPT plan, or an OpenAI API key per token | Whichever provider you connect, by key or by sign-in |
Sandbox | bubblewrap and seccomp on Linux, network off | None built in |
Asks before acting | Only to leave the sandbox, by default | Never |
Scripted runs | codex exec, read-only by default | pi -p, all default tools |
Instructions | AGENTS.md | AGENTS.md or CLAUDE.md |
Sign-in on a server | codex login --device-auth | pi auth login <provider> --no-browser |
Update | codex update | pi update |
Licence
Unlike Claude Code, Codex is open source: the openai/codex repository is under the Apache License 2.0, and the npm package @openai/codex says the same. Pi’s repository is MIT. Either can be read, forked and patched, so the licence rarely decides between them. What differs is who steers: Codex is OpenAI’s client for OpenAI’s service, and Pi is a harness whose README says it “ships with powerful defaults but skips features like sub-agents and plan mode.” The guide to Pi covers what it leaves out and why.
Models, plans and what it costs
Codex is OpenAI-first. Signed in with ChatGPT, it runs the models your plan includes; on an API key, OpenAI’s auth page says it bills at “standard API pricing instead of included ChatGPT plan credits.” It can leave OpenAI: its advanced config page reserves built-in providers named openai, ollama, lmstudio, amazon-bedrock and gcp, runs a local model through Ollama or LM Studio with --oss, and takes other endpoints as [model_providers.<id>] entries in ~/.codex/config.toml, with a Mistral endpoint among its examples. Those keys are ignored in a project’s own config, so a repository cannot redirect your agent to another endpoint.
Pi has no home provider. Its site lists Anthropic, OpenAI, Google, Azure, Bedrock, Mistral, Groq, Cerebras, xAI, OpenRouter, Ollama and more, connected by API key or by signing in. Pi itself is free; the bill is whichever provider you point it at.
Both sign in to a ChatGPT account, and the two do it differently. In Codex it is the main route: which ChatGPT plans include Codex sets out what each plan from Free to Enterprise gets, with Plus at $20 a month on OpenAI’s pricing page. Pi signs in to a ChatGPT account through its own OpenAI sign-in provider, which sends you to the same device page as Codex. OpenAI’s Sign in with ChatGPT page sorts outside apps into three lists: “Apps with ChatGPT plan usage”, “Apps with sign-in only”, and “Open-source integrations”, which names OpenClaw, OpenCode, Pi and T3 and says nothing further about them. Its general rules are that “eligible ChatGPT Go, Plus, Pro, and Business subscribers can also choose to use their ChatGPT plan for AI requests”, that “App usage counts toward your existing plan limits”, and that “Connecting an app does not add a new allowance.” By those rules, whatever an app draws from your plan comes out of the same allowance Codex uses.
Sandbox and approvals
This is the sharpest difference. Codex sandboxes the commands it runs. OpenAI’s security page says “Linux uses bwrap plus seccomp by default” and that “the agent runs with network access turned off.” In a Git repository the default is Auto: it may edit the working folder and run commands there without asking, and asks before anything the sandbox would block, such as a write elsewhere or a download. Outside version control it starts read-only. .git stays read-only even inside the writable folder. The modes run from read-only to danger-full-access, and --ask-for-approval never turns the questions off.
On a server, the sandbox is also the part most likely to need work: on Ubuntu 24.04 bubblewrap cannot create its user namespace until AppArmor allows it, and every command fails until then. Codex on a Linux server has the fix, and each bubblewrap warning and error its causes.
Pi has neither. Its security guide says Pi “does not ask for approval before every tool call”, tells you to “Treat model-generated commands and code as untrusted”, and calls running it inside a container, virtual machine or sandbox “usually the strongest practical option.” What you have instead: a confirmation step as an extension, which Pi’s docs list as an example use, and the choice of tools for a run. Leaving out bash, edit and write gives a run that can only look, as in the CLI reference’s own example:
pi --tools read,grep,find,ls --print "Review this project"CopiedPi does ask one question: whether to trust a project before loading its .pi/ settings, extensions, skills and MCP servers. That decides what loads, not what the agent may touch.
Skills, MCP and instructions
The two are closer here than anywhere else, and much of a setup carries across.
- Skills. Both follow the Agent Skills format and both read
~/.agents/skills/and a project’s.agents/skills/, so a skill in one of those folders is found by either agent without copying. Codex also reads/etc/codex/skillsand ships its own system skills; its skills page has the list. You call one by name with$namein Codex and/skill:namein Pi, or let the model pick it. - MCP servers. Both are added the same way:
codex mcp add <name> -- <command>writes an[mcp_servers.<name>]table to~/.codex/config.toml, andpi mcp add <name> -- <command>writes to~/.pi/agent/mcp.json. Each loads a project’s own servers only once the project is trusted. Pi by default lets the model reach MCP tools through short scripts rather than listing every tool; Pi’s MCP servers covers that. - Extending further. Codex adds plugins, which bundle skills and MCP servers and can carry lifecycle hooks. Pi’s extensions are “TypeScript modules that extend Pi’s behavior”: tools the model can call, commands, model providers, MCP servers, or a plan mode of your own. An extension “runs inside the Pi process with the same operating-system permissions”, so install only what you would run yourself.
- Instructions. Codex reads
AGENTS.override.mdorAGENTS.mdfrom~/.codexand from each folder between the project root and where you started it, up to 32 KiB by default; other file names are added withproject_doc_fallback_filenames. Pi readsAGENTS.mdorCLAUDE.mdwith no setting, so a repository written for Claude Code works in Pi as it is.
Scripted and scheduled runs
codex exec and pi -p both run one prompt and print the final answer, and both have a JSON event stream (codex exec --json, pi --mode json). They start from opposite ends.
- What the run may do. OpenAI’s non-interactive page: “By default,
codex execruns in a read-only sandbox.” A job that edits needs--sandbox workspace-write, and it refuses to run outside a Git repository unless you pass--skip-git-repo-check.pi -pruns with its default tools,read,bash,editandwrite, and nothing in between. - What a project may load. Codex loads a project’s config and MCP servers “only for trusted projects, even in a writable sandbox”;
--trustrecords trust for the folder. Pi’s print, JSON and RPC modes “cannot show the built-in trust prompt”, so with the default setting a project’s.pi/resources are skipped unless the run passes--approve. When a scheduled job seems to run without a project’s own MCP server or extension, trust is the first thing to check. - Billing a job separately.
CODEX_API_KEYset for a singlecodex execputs that run on an API key instead of your plan. In Pi, choose the provider and model for the run with--model provider/id. - Picking up again.
codex exec resume --lastcontinues the last run; Pi’s--continue“Continues the most recent session for the current directory.”
Pi also has an RPC mode, which takes commands on standard input from another program, for driving it from your own tool.
Signing in on a server with no browser
Both use a device code, and for a ChatGPT account both send you to the same OpenAI page, auth.openai.com/codex/device, where you enter a one-time code from any phone or laptop within 15 minutes:
codex login --device-auth # Codex
pi auth login <provider> --no-browser # Pi; pick its ChatGPT sign-inCopiedFor Codex, device-code sign-in has to be switched on first, in ChatGPT’s security settings for a personal account or by an admin for a workspace; the device-code guide covers the message you get while it is off. pi auth login, new in 1.5.1, takes any provider: with --no-browser it uses “the provider’s other sign-in method, such as a device code, for example over SSH”, and with --api-key it saves a key without echoing it; signing Pi in on a server goes provider by provider.
Codex keeps its sign-in in ~/.codex/auth.json, which OpenAI’s auth page calls a plaintext file, or in the system’s credential store if you configure one; Pi keeps keys and tokens in ~/.pi/agent/auth.json. Run both as one user and each can read the other’s file. One clash on a shared machine: Pi’s browser sign-in for a ChatGPT account listens on port 1455, the same port as codex login, and its source notes it falls back to a pasted redirect URL when Codex holds it.
Installing and updating
curl -fsSL https://chatgpt.com/codex/install.sh | sh # Codex
curl -fsSL https://pi.dev/install.sh | sh # PiCopiedBoth also come from npm: npm install -g @openai/codex needs Node.js 16 or newer, and npm install -g --ignore-scripts @earendil-works/pi-coding-agent needs 22.19 or newer. Each updates itself with one command, codex update (“Update Codex to the latest version.”) and pi update, which with no target updates Pi rather than its packages. The detail, and what to do when an update fails, is in updating Codex and installing Pi on Linux.
Who each fits
- You pay for ChatGPT and want OpenAI’s models: Codex. It is OpenAI’s own client for the plan, and the one OpenAI’s Codex pricing describes.
- You want a sandbox and approvals without building them: Codex, once bubblewrap works on the machine.
- You want Claude, Gemini, open-weight models and GPT side by side, or to switch mid-project: Pi.
- You want a small prompt and only the features you add: Pi.
- Your repositories carry
CLAUDE.md: Pi reads it as it is; Codex needs it named as a fallback. - You will leave it working unattended: either, on a machine or container of its own. Codex’s sandbox narrows what a run can touch; Pi relies on the machine for that.
Neither choice locks you in: they share skills folders and MCP setup, and both sign in to a ChatGPT account. For the same comparison against other agents, see Pi vs OpenCode and Codex vs Claude Code.