How do I track the cost of each session in Codex (beta)?
Rius records the cost of each Codex (beta) session as one trace, with tokens and cost on every model call. Install the Rius plugin, sign in, and run $rius:rius-enable-here in a repo, and each session shows up in the trace list with its cost. The Agents and Users pages add the totals for the agent and for each developer. Codex support is in beta and needs plugin 0.6.0 or later.
How it works
The Rius plugin hooks into Codex (beta) and sends each CLI session to Rius as one trace. Resuming a session with codex resume or codex exec resume continues the same trace.
Inside the trace, each prompt is a turn, and each model call under it records the model and its input, cached, output and reasoning tokens. Rius works out the cost of each call from the model and those token counts, in US dollars, using LiteLLM’s public model-price catalog. You never send a cost value. A model missing from the catalog gets an empty cost, not zero.
The cost is a list-price estimate at API rates. On a ChatGPT plan it measures usage and is not what you pay.
Structure-only tracing, the default, already includes models, tokens and cost. You do not need to send prompts or replies to see what a session cost. Subagents that Codex (beta) starts appear nested under the call that started them, with their own model calls, so their cost is visible separately.
Codex (beta) does not tell plugins when a session ends. A trace closes when you start the next Codex (beta) session on the same key, once the old session’s process has exited and it has been idle for about an hour. Until then the trace shows as in progress.
Set it up
-
Install the plugin from a terminal. 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 no message tells you. -
Sign in with
$rius:rius-login. Approve the sandbox escalation, pick the workspace in the browser, and click Connect. Sign-in stores a key for this machine. -
In the repo you want to measure, run
$rius:rius-enable-here. This sends the span tree, models, tokens, cost and timing, with no prompts or tool output. Use$rius:rius-enable-content-hereif you also want prompts, replies and tool output, with recognised secrets removed on a best-effort basis. -
Run
$rius:rius-status. It shows whether the folder is traced and why, and theHooks:line counts the approved hooks. If it shows fewer than five, return to step 2. -
Work in Codex (beta) as usual, then open the trace list in the console at
console.rius-glassflow.com.
For the full walkthrough, including the terminal fallback for sign-in, see the Codex (beta) guide.
To ask for cost in plain language, run codex mcp login rius once. This is a second sign-in, separate from $rius:rius-login. Then ask Codex (beta) something like “Which of my Codex sessions this week used the most tokens?”
What you get
- Cost per session in the trace list. Each session is one row, and opening it shows tokens and cost on every model call, so you can go from an expensive session to the exact step.
- Cost for the agent. Sessions appear on the Agents page as an agent named
codex, with traces, errors and cost for the selected window. An open session shows as a live instance. These figures count a session only once its trace has closed. - Cost per developer. From plugin 0.6.2, each span carries
user.id, set to the email you signed in with. Sessions then appear under your name on the Users page with their cost, and you can sort by Cost. The Sent by column in the trace list shows whose key sent each session. Sessions sent with a key you stored withuse-keycarry no user and land in the anonymous row. - Answers from the terminal. The plugin registers the Rius MCP server as
rius, so you can query sessions from Codex (beta) itself.
What Codex (beta) does not report:
- OpenAI does not report cache-write tokens, so none are shown.
codex exec --ephemeralsessions are not traced, because Codex (beta) keeps no record for the plugin to read.- Model-call start times are approximate.
- Windows is untested for Codex (beta).
The plugin also ignores RIUS_API_KEY and RIUS_ENDPOINT set in the environment. It uses only a key you stored yourself.
When something else fits
- If you roll out Claude Code to a team, the same plugin and pages apply. See Track Claude Code usage and cost across a team.
- Cursor (beta) traces carry no token counts or cost, so it cannot answer this question. See Coding agents for how each agent compares.
- If you need what you actually pay on a subscription plan, Rius shows usage at API list prices, not your bill.