Codex CLI
Track every OpenAI Codex CLI turn: prompts, responses, tool calls (shell, apply_patch, web search and custom tools), token usage including cached and reasoning tokens, and estimated cost. Install one hook per machine.
%%{init: {"flowchart": {"curve": "linear"}}}%%
graph LR
A["Codex turn completes"] --> B["Codex calls<br/>anosys-codex run"]
B --> C["Reads the turn from<br/>the local session log"]
C --> D["Optional redaction"]
D --> E["Claude Code & Codex CLI<br/>endpoint"]
D -.->|offline| F["Saved locally,<br/>sent on next run"]
Step 1. Get an API key
Create an endpoint of type Claude Code & Codex CLI (or pick the Codex goal during onboarding) and copy its API key from Collecting → Integration Options → API. Keys from other endpoint types are rejected by the installer.
Step 2. Install
The installer asks for your API key, whether to turn on content redaction (prompts, answers, code and tool input/output replaced with [REDACTED]), and whether to add the hook to ~/.codex/config.toml for you. It saves a backup of config.toml first.
Step 3. Approve the hook in Codex
Codex asks you to trust new hooks once. Start Codex, type /hooks, and approve the anosys-codex run entry.
Don't skip this step
Until the hook is approved, Codex doesn't run it and nothing is sent.
Step 4. Check it works
Run one Codex turn. The endpoint's activity graph shows calls within seconds.
Install without prompts
| Flag | What it does |
|---|---|
--api-key KEY |
Your API key (or set ANOSYS_API_KEY before running) |
-y, --yes |
Accept defaults, no prompts |
--redaction / --no-redaction |
Turn content redaction on or off |
--auto-update |
Write ~/.codex/config.toml without asking |
--no-auto-update |
Print the lines to add by hand instead |
You still need to approve the hook once in Codex (step 3).
Commands
| Command | What it does |
|---|---|
anosys-codex install |
Add or update the hook |
anosys-codex status |
Show whether the hook is registered and configured |
anosys-codex uninstall |
Remove the hook from config.toml and delete its settings file |
anosys-codex run |
What Codex calls after each turn. You don't run it yourself. |
Settings
| Variable | What it does |
|---|---|
ANOSYS_HOOK_APIKEY or ANOSYS_API_KEY |
API key |
REDACTION or ANOSYS_REDACT_CONTENT |
true to redact content |
ANOSYS_HOOK_DRY_RUN |
true to print what would be sent instead of sending it |
CODEX_HOME |
Use a Codex folder other than ~/.codex |
ANOSYS_ENCRYPTION_KEY |
Optional passphrase to encrypt content fields before sending. See Security and data controls. |
What you get
| Spend | Input, cached input, output and reasoning tokens; estimated cost in USD |
| Activity | Prompts and responses, tool calls, shell commands, patches |
| Context | Developer, working folder, model |
| Reliability | Turns are saved locally when you're offline and sent on the next run |
Costs are estimates based on public model prices.
Troubleshooting
Nothing shows up in the console
- Did you approve the hook with
/hooksinside Codex? - Run
anosys-codex status. - Check the key belongs to a Claude Code & Codex CLI endpoint.
- Allow outbound HTTPS to
api.anosys.ai.