# Codex

URL: https://docs.hanzo.ai/docs/guides/coding/codex

> Run Codex with `hanzo --codex`: on your ChatGPT plan with the Hanzo toolset beside it, or fully on Hanzo with `--cloud`.

## Set up

```bash
curl -fsSL hanzo.sh | sh
hanzo login
hanzo --codex
```

Give it a task as one quoted argument to run it headless: `hanzo --codex "port this module to the new store"`. Codex is its own tool here, never an alias of Hanzo Dev (`hanzo dev`), which shares its driver.

## On your ChatGPT plan (the default)

Codex uses its own login, ChatGPT plan or API key, and the wrapper leaves its environment alone. It adds:

- **The Hanzo toolset**, through Codex's `-c mcp_servers.hanzo.*` overrides. Your own `config.toml`, your servers and your `codex login` are untouched, because the wrapper never repoints `CODEX_HOME`. Codex can then hand work to Enso (`llm`), Kai (`kai_decide`) and Hanzo's search tools, billed to your Hanzo plan.
- **The session** is registered in the cloud and, for a headless run, its events stream there. Pass `--no-link` to keep it local.
- **The summary** at the end names every toolset call and the model it reached.

## Fully on Hanzo (`--cloud`)

```bash
hanzo --codex --cloud
```

Model calls go through Codex's `hanzo` provider at `https://api.hanzo.ai/v1`, with your Hanzo token in `HANZO_USER_KEY`. The model is `enso-auto` unless you set another with `--model` or in `~/.hanzo/settings.json`. Usage is metered into your org at api.hanzo.ai, and your org's cloud tools are added beside the toolset.

## What the wrapper leaves to you

Your `config.toml` wins where it sets a value. The wrapper adds `approval_policy` and `sandbox_mode` only when your file leaves them unset, and it keeps the workspace sandbox. `--no-sandbox` drops the sandbox and approvals for one run; `--ask` leaves Codex asking.

## See usage

```bash
hanzo console          # press 6 for Savings
hanzo usage summary --range 7d
```

[How to read the summary →](https://docs.hanzo.ai/docs/guides/coding#what-a-session-used)
