Codex
Use Codex through AnyAgent: what you can ask for, how it behaves, and the flags underneath.
The codex adapter drives the Codex CLI through its non-interactive codex exec --json mode, detected as the codex binary on PATH; import codex from anyagent-js/codex.
What you can ask for
readOnly, model, effort, resume, and attachments map to the CLI’s own flags; systemPrompt and schema are provided by AnyAgent. mcp is not declared; reach Codex’s -c config overrides via extraArgs. authStatus() asks codex login status (a ChatGPT login asserts billing: "subscription"), models() asks codex debug models, and usageStatus() asks the CLI’s app-server for live rate-limit standing. The full grid is on the support matrix.
Good to know
efforthas no closed vocabulary; accepted values are per-model, listed bymodels()onModelInfo.reasoningEfforts.- The
thread.startedid lands onresult.sessionId; pass it back asresume. - Cache reads fold into the input total and reasoning into the output total;
cacheReadTokensandreasoningTokensreport those shares, not additions. No cost is reported. - Codex meters separately per feature, so
usageStatus()can return more than one set of windows. Labels are prefixed with the feature they belong to (codex:primary), and the same answer carries the credit balance oncredits. - Read
windowMinutes, never the label, to tell a 5-hour window from a weekly one. OpenAI has shipped the weekly number under the labelprimarywith no second window at all, so position says nothing about length. - The limits come from
codex app-server, a separate process from the one that runs prompts. Asking costs a short handshake and no model call.
Under the hood
Every run executes codex exec --json --sandbox danger-full-access with the prompt piped over stdin through the - positional. Run options change the sandbox and append flags:
| Option | Flag |
|---|---|
readOnly: true | --sandbox read-only |
model | --model <name> |
effort | -c model_reasoning_effort="<value>", passed through verbatim |
attachments | -i <file>…, every path on one flag, ahead of the - stdin positional |
resume | codex exec resume <threadId>, with the sandbox set via -c sandbox_mode="…" |