How do I track token usage in Codex (beta)?
Rius records the tokens of every Codex (beta) model call once you install the Rius plugin and turn tracing on for a folder. Each Codex (beta) session becomes one trace, and each model call in it carries its input, cached, output and reasoning tokens plus a cost estimate. You read the figures in the trace list, on the Agents page and on the Users page.
How it works
The Rius plugin hooks into the Codex CLI (beta) and sends each session to Rius as a trace. Tokens sit on the span for each model call, so you can go from a session total to the single call that used the most.
AGENT codex session
└─ CHAIN a turn: one prompt and everything it caused
└─ LLM a model call: model, input, cached, output, and reasoning tokens
├─ TOOL a tool call
└─ TOOL spawn_agent: the call that started a subagent
└─ AGENT the subagent, with its own turns and calls- Tokens are on by default. A folder enabled for structure only still sends model names, tokens and cost. Prompts, replies and tool output stay out unless you enable content for that folder.
- Subagents count too. A subagent that Codex (beta) starts appears nested under the call that started it, with its own model calls and tokens.
- Cost is an estimate. Rius works it out from the token counts at API rates, so on a ChatGPT plan it measures usage, not what you pay.
- Cache writes are not reported. OpenAI does not report cache-write tokens, so Rius shows none for Codex (beta).
- Ephemeral runs are not traced.
codex exec --ephemeralsessions leave no record for the plugin to read, so their tokens never reach Rius.
For a comparison of what each coding agent reports, see Coding agents.
Set it up
You need plugin version 0.6.0 or later, Python 3.9 or later on your PATH, and macOS or Linux. Windows is untested for Codex (beta). The plugin is tested with codex-cli 0.144.1.
-
Install the plugin. Installing sends nothing, and tracing stays off for every folder until you enable one.
codex plugin marketplace add glassflow/rius-coding-agents codex plugin add rius@rius-coding-agents -
Trust the hooks. In Codex (beta), open
/hooksand trust the fiveriushooks. Until you do, nothing is traced and Codex does not tell you. -
Sign in. Type
$rius:rius-login, approve the sandbox escalation, pick a workspace in the browser and click Connect. -
Turn tracing on for a folder. In your repo, run
$rius:rius-enable-here. Use$rius:rius-enable-content-hereinstead if you also want prompts and replies sent, with recognised secrets removed on a best-effort basis. -
Check the state. Run
$rius:rius-status. It shows whether the folder is traced and why, the account, the key, and how many hooks are approved. If fewer than five are approved, go back to step 2. -
Work as usual. Open the session in the trace list at
console.rius-glassflow.comand look at the model calls.
The full walkthrough, including signing out and troubleshooting, is on the Codex (beta) page.
What you get
- Tokens per model call. Open a session in the trace list and the span for each model call shows its model and its input, cached, output and reasoning tokens, with the estimated cost.
- A session total. Each session is one trace, and resuming it with
codex resumeorcodex exec resumecontinues the same trace. - An agent view. Sessions appear as an agent named
codexon the Agents page. An open session is a live instance. The agent’s trace, error and cost figures count a session only after its trace has closed. - Usage per developer. With plugin 0.6.2 or later, each span carries your sign-in email as
user.id, so sessions show under your name on the Users page. The Sent by column in the trace list shows whose key sent each trace. Sessions sent with a key stored byuse-keycarry no user and land in the anonymous row. - Questions in plain language. Run
codex mcp login riusonce, a second sign-in separate from$rius:rius-login. Then ask Codex (beta) “Which of my Codex sessions this week used the most tokens?”
One timing detail matters when you compare totals. Codex (beta) does not tell the plugin when a session ends, so a trace closes when you start your next session on the same key, after the old session’s process has exited and it has been idle for about an hour. Until then it shows as in progress.
When something else fits
- If you want the same view for another agent, Track Claude Code usage and cost across a team covers per-developer tokens and cost for Claude Code.
- If you need exact billing figures, use your provider’s own usage page, because Rius shows list-price estimates from token counts.