# Codex

## Install

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

## Sign in

```bash
codex login
```

Sign in with your ChatGPT account, so Codex uses your ChatGPT plan. Prefer an API key? Set `OPENAI_API_KEY` in your shell profile instead. Get a key from [platform.openai.com/api-keys](https://platform.openai.com/api-keys).

Check you're signed in with `codex login status`.

## Launch

Press <KeyCombo keys={["⌘", "⌥", "4"]} /> or open the Command Palette → **Add Codex**.

<TerminalPreview lines={[
  { type: "command", text: "codex" },
  { type: "output",  text: "Codex CLI v0.1" },
  { 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" }
]} />

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

Pane's **Add Codex** button starts Codex as `codex --yolo`. That skips approval prompts and the sandbox, so the agent can work without stopping to ask. The pane's worktree keeps its changes away from your main branch, but the agent can still run any command on your machine. Want it to ask first? Add Codex as a [custom command](/docs/custom-agents) with your own flags.

**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>
