# Codex

Codex, from OpenAI. See the [Codex documentation](https://developers.openai.com/codex) for its current Node and dependency requirements before installing, since those change independently of this page.

## Install

Use Codex CLI 0.162 or later.

```sh
npm install -g @openai/codex
codex --version
```

On Linux, the Codex sandbox needs `bwrap` from the `bubblewrap` package. macOS works as is.

## Download the profile and catalog

Codex runs K2 Horizon from two files in `~/.codex/`. Use them unchanged.

```sh
mkdir -p ~/.codex
curl -fsSL -o ~/.codex/k2.config.toml https://docs.ifm.ai/codex/k2.config.toml
curl -fsSL -o ~/.codex/k2_catalog.json https://docs.ifm.ai/codex/k2_catalog.json
```

| File | What it does |
| --- | --- |
| `k2.config.toml` | The `k2` profile: the IFM endpoint, high reasoning effort, web search off, and the Codex plan checklist (`update_plan`) on. |
| `k2_catalog.json` | Tells Codex the model's context window (524,288 tokens), its reasoning levels, and Codex's own instructions with one change: the API can't run Codex's `apply_patch` tool, so the model edits files with shell commands (`sed`, `cat > file`, small Python scripts) instead. |

Without the catalog, Codex tells the model to use `apply_patch`, and turns end with raw `<ifm|tool_calls>` text.

`~/.codex/k2.config.toml`

```toml
# Codex profile for K2 Horizon on the IFM API.
# Save as ~/.codex/k2.config.toml and run:  codex --profile k2
# It only applies when you pass --profile k2; your normal Codex setup is unchanged.

model = "IFM/K2-Horizon-375B-A23B"
model_provider = "ifm"
model_reasoning_effort = "high"      # K2 Horizon supports high only
model_catalog_json = "~/.codex/k2_catalog.json"
web_search = "disabled"              # the API can't run Codex's built-in web search

[model_providers.ifm]
name = "IFM"
base_url = "https://api.ifm.ai/v1"
env_key = "IFM_API_KEY"
wire_api = "responses"

# Codex leaves its plan tool off for models it doesn't know; this turns it on so
# multi-step tasks show a checklist.
[tools.update_plan]
enabled = true
```

## Set the API key

```sh
export IFM_API_KEY=...
```

## Run

Start Codex in a project folder:

```sh
codex --profile k2
```

Your normal Codex setup is untouched; only `--profile k2` uses IFM. A warning that the `priority` service tier isn't supported is harmless.

To check the setup, run a one-line turn; it should reply `IFM_OK`:

```sh
codex exec --profile k2 --skip-git-repo-check "Reply with exactly IFM_OK"
```

Then run a tool-using turn; it should create `hello.txt` and reply `HELLO_K2`:

```sh
mkdir -p /tmp/k2-check && cd /tmp/k2-check
codex exec --profile k2 --skip-git-repo-check --sandbox workspace-write \
  "Create a file named hello.txt containing the line HELLO_K2, then run cat hello.txt and reply with exactly what it printed."
```

## Notes

- Keep reasoning effort on `high`. K2 Horizon: `high` only.
- Occasionally the model calls a tool that doesn't exist, and the reply shows raw `<ifm|tool_calls>` text. The turn then ends; ask it to continue.
- Not supported: image input, web search, `apply_patch`.

## Troubleshooting

| Symptom | Fix |
| --- | --- |
| Raw `<ifm\|tool_calls>` text mentioning `apply_patch` or `update_plan` | Download both files again and use them unchanged. |
| `401 Unauthorized` | Check `IFM_API_KEY` is set to a valid key. |
| `Missing environment variable: IFM_API_KEY` | Export it in the shell where Codex runs. |
| Codex uses its usual model | Start Codex with `--profile k2`. |
| Sandbox errors on Linux | Install `bubblewrap`. |

_Last updated: November 11, 2026_
