Model and API parameter reference plus setup guidance for building with OpenAI's Codex/code-focused models.
Sign in with your ChatGPT plan (Plus, Pro, Business, Edu, Enterprise) — that is the recommended path and needs no API key. An API key works too but requires extra setup and bills separately.
| Subcommand | Purpose |
|---|---|
codex | Interactive TUI session. The default. |
codex exec "task" | Non-interactive. The scriptable surface — run a task, get output, exit. This is what you use in CI. |
codex review | Run a code review non-interactively. |
codex apply | Apply the agent's latest diff as a git apply. |
codex resume / fork | Resume or branch a previous session — picker by default. |
codex queue | Queue a message for an existing session. |
codex archive / unarchive / delete | Session lifecycle management. |
codex agents | Browse all agent sessions on the shared local daemon. |
codex sandbox | Run arbitrary commands inside Codex's sandbox — useful on its own. |
codex mcp | Manage external MCP servers. |
codex mcp-server | Runs Codex itself as an MCP server over stdio, so another agent can drive it. |
codex plugin | Manage Codex plugins. |
codex login / logout | Authentication. |
codex doctor | Diagnose the install and update to the latest version. |
codex completion | Generate shell completion scripts. |
codex cloud | Experimental — browse Codex Cloud tasks and apply changes locally. |
codex execpolicy | Execution-policy tooling. |
codex features | Inspect feature flags. |
AGENTS.mdis Codex's project-instruction file — the equivalent ofCLAUDE.md. Generate one with/init.- It is an open, cross-tool convention, not an OpenAI-only format — several agents read it.
- Config lives in
~/.codex/config.toml. Admins can enforce policy throughrequirements.toml, includingallow_managed_hooks_onlyto ignore user and project hook configs. /importpulls your setup, project config and recent chats across from Claude Code — a genuinely useful migration path in either direction.
| Group | Command | What it does |
|---|---|---|
| Session | /model | choose what model and reasoning effort to use |
| Setup | /ide | — |
| Security | /permissions | choose what Codex is allowed to do |
| Setup | /keymap | remap TUI shortcuts |
| Setup | /vim | toggle Vim mode for the composer |
| Security | /setup-default-sandbox | set up elevated agent sandbox |
| Security | /sandbox-add-read-dir | — |
| Setup | /experimental | toggle experimental features |
| Security | /approve | approve one retry of a recent auto-review denial |
| Context | /memories | configure memory use and generation |
| Setup | /skills | use skills to improve how Codex performs specific tasks |
| Setup | /import | import setup, this project, and recent chats from Claude Code |
| Setup | /hooks | view and manage lifecycle hooks |
| Code | /review | review my current changes and find issues |
| Session | /rename | rename the current thread |
| Session | /new | start a new chat during a conversation |
| Session | /archive | archive this session and exit |
| Session | /delete | permanently delete this session and exit |
| Session | /resume | resume a saved chat |
| Session | /fork | fork the current chat |
| Surfaces | /app | continue this session in the Desktop app |
| Context | /init | create an AGENTS.md file with instructions for Codex |
| Context | /compact | summarize conversation to prevent hitting the context limit |
| Session | /plan | switch to Plan mode |
| Session | /goal | set or view the goal for a long-running task |
| Agents | /agents | view and switch between all active agent sessions |
| Agents | /side | — |
| Session | /btw | — |
| Output | /copy | copy the last response, code block, or quote |
| Output | /export | export the conversation as markdown |
| Output | /raw | toggle raw scrollback mode for copy-friendly terminal selection |
| Code | /diff | show git diff (including untracked files) |
| Context | /mention | mention a file |
| Info | /status | show current session configuration and token usage |
| Files | /cd | change the current working directory |
| Files | /pwd | show the current working directory |
| Info | /usage | view account usage or use a usage limit reset |
| Info | /debug-config | show config layers and requirement sources for debugging |
| Setup | /title | configure which items appear in the terminal title |
| Setup | /statusline | configure which items appear in the status line |
| Setup | /theme | choose a syntax highlighting theme |
| Extras | /pets | choose or hide the terminal pet |
| Integrations | /mcp | list configured MCP tools; use /mcp verbose for details |
| Integrations | /apps | manage apps |
| Integrations | /plugins | browse plugins |
| Account | /logout | log out of Codex |
| Session | /quit | — |
| Session | /exit | exit Codex |
| Info | /feedback | send logs to maintainers |
| Info | /rollout | print the rollout file path |
| Processes | /ps | list background terminals |
| Processes | /stop | stop all background terminals |
| Session | /clear | clear the terminal and start a new chat |
| Setup | /personality | choose a communication style for Codex |
| Agents | /subagents | switch between this session's subagents |
Generating images
| Model | Notes |
|---|---|
| gpt-image-2 | Current flagship. Accepts custom resolutions, not just fixed presets. |
| gpt-image-1.5 | Previous generation. |
| gpt-image-1 | Older. |
| gpt-image-1-mini | Smaller and cheaper. |
- Common sizes:
1024x1024,1536x1024,1024x1536,2048x2048,3840x2160. Default isauto. - Max edge 3840px. Dimensions must be multiples of 16.
- Aspect ratio capped at 3:1 — no ultra-wide banners in one shot.
- Total pixels must fall between 655,360 and 8,294,400.
quality:low/medium/high/auto.output_compression(0–100) applies to JPEG and WebP only.- Output is base64-encoded in the response — you decode and write the file yourself.
PDFs, ZIPs and everything else
- A container expires after 20 minutes idle, and expired containers are inaccessible. Download generated files before then — this is the single most common way people lose output.
- Memory tiers: 1 GB (default), 4 GB, 16 GB, 64 GB. Set
memory_limitat creation for anything data-heavy. - Rate limit: 100 requests per minute per organisation.
- Files are retrieved by
container_file_citationannotation, not returned inline — you must make a second call per file. - Inputs it accepts: CSV, JSON, PDF, XLSX, DOCX, PPTX, images, source code, ZIP and TAR archives.
| How | Formats | Needs |
|---|---|---|
| Written directly | .md .txt .csv .tsv .json .yaml .toml .xml .html .svg .css .js .ts .py .rs .go .sh .sql .ipynb .env and any other plain text | Nothing. No code executed, no library required. |
| Script | .pdf | reportlab, weasyprint, or render HTML → PDF. Merging and form-filling via pypdf. |
| Script | .xlsx .xlsm | openpyxl for formulas and formatting, pandas for bulk data. |
| Script | .docx .pptx | python-docx, python-pptx, or the JS equivalents. |
| Script | .zip .tar .tar.gz .gz | Shell zip/tar, or Python zipfile/tarfile. Nothing to install. |
| Script | .png .jpg .webp .gif | matplotlib / plotly for charts, Pillow for manipulation. Rendered from code, not drawn. |
| Script | .parquet .sqlite .db .feather | pandas, pyarrow, sqlite3. |
| API call | .png .jpeg .webp from a prompt | An OpenAI API key and gpt-image-2. The only format generated by a model rather than by code. |
- Context, not file size, is the constraint. Reading a large CSV into the conversation wastes the window and degrades the answer. Tell Codex to process it with pandas instead — the file then never enters context and size stops mattering.
- The sandbox governs where files can be written. Codex confines writes by default;
/permissionsand/setup-default-sandboxcontrol it. A script that writes outside the workspace will be blocked, not silently fail. - XLSX caps at 1,048,576 rows × 16,384 columns per sheet — an Excel format limit, not a Codex one. Beyond that, split sheets or use Parquet.
- Codex cannot see the rendered output. It writes plotting code without looking at the chart, so clipped labels and unreadable colour choices go unnoticed unless you check.
- Missing libraries are a permission prompt, not magic — Codex will offer to install them.
Gotchas
- The old Codex model is dead. Any tutorial referencing
code-davinci-002is describing a product retired in 2023 and unrelated to this one. - Container files vanish after 20 minutes idle. If you build a pipeline on Code Interpreter, download before the container expires or the output is gone.
- Images return as base64, not a URL. You decode and save them yourself.
- Image dimensions must be multiples of 16, max edge 3840, aspect ratio within 3:1. Requests outside those bounds are rejected rather than clamped.
- Piping an install script straight to a shell is convenient, not careful. Release binaries are on GitHub if you would rather inspect first.
codex mcp-servermakes Codex controllable by another agent — powerful, and worth understanding before enabling.- Codex moves fast; the CLI is Rust and Apache-2.0, so when docs and behaviour disagree, the repo is the answer.
Tips
codex exec for automationThe non-interactive surface. Run a task, capture stdout, exit with a status code — the right entry point for CI, cron and scripts.
/import from Claude CodeBrings your setup, project config and recent chats across. If you are evaluating both, this removes most of the switching cost.
AGENTS.md/init generates one. It is a cross-tool open convention, so the same file guides several agents — not effort spent on one vendor.
/permissions and /setup-default-sandbox decide what Codex may touch. Choose once, properly, rather than approving prompt after prompt.
/ps and /stopBackground terminals keep running. /ps lists them, /stop kills them all — useful after a session that spawned dev servers.
Code Interpreter defaults to 1 GB. Pass memory_limit="4g" or higher at creation for real datasets — you cannot resize it later.
Resources
/import moves your setup between them.
www.ty1er.com
OpenAI ChatGPT
The consumer product, and where a paid plan unlocks Codex.
www.ty1er.com