# Codex

Codex runs in its own tab in each [pane](/docs/panes-and-worktrees), on that pane's branch.

## Install

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

Or with npm:

```bash
npm install -g @openai/codex
```

## Sign in

```bash
codex login
```

Sign in with your ChatGPT account, so Codex uses your ChatGPT plan. Check you're signed in with `codex login status`.

Prefer an [API key](https://platform.openai.com/api-keys)? Set `OPENAI_API_KEY`, then run `printenv OPENAI_API_KEY | codex login --with-api-key`.

## Launch

Press <KeyCombo keys={["⌘", "⌥", "4"]} /> (<KeyCombo keys={["Ctrl", "Alt", "4"]} /> on Windows and Linux) or press <KeyCombo keys={["⌘", "⇧", "P"]} /> (Open Search) and choose **Add Codex**.

<TerminalPreview lines={[
  { type: "command", text: "codex --yolo" },
  { type: "output",  text: "" },
  { type: "command", text: "Fix the failing tests in auth module" },
  { type: "success", text: "✓ Updated src/auth.test.ts" },
  { type: "success", text: "✓ All tests passing" }
]} />

> **Warning:** Pane starts Codex as `codex --yolo`, which skips approval prompts and the sandbox, so it can run any command on your machine. To have it ask first, add Codex as a [custom command](/docs/custom-agents) with your own flags.

Review the changes in **Changes** (<KeyCombo keys={["⌘", "⌥", "B"]} />), then commit with <KeyCombo keys={["⌘", "⇧", "K"]} />.

Pane remembers each Codex tab's conversation. After a restart, use **Resume Previous Panes** to resume it with `codex resume`.

<Toggle title="Sandbox, model and approvals">

**Sandbox**: limits what Codex's shell commands can touch:

```bash
codex --sandbox workspace-write
```

The options are `read-only`, `workspace-write` and `danger-full-access`.

**Approvals**: choose when Codex asks before running a command:

```bash
codex --ask-for-approval on-request
```

`on-request` lets the model decide when to ask. `never` never asks.

**Model**: override the default model:

```bash
codex --model <model-id>
```

Run `codex --help` for everything else.

</Toggle>
