Implement /cost command and track session usage
Resolved 💬 9 comments Opened Apr 16, 2025 by banteg Closed Aug 7, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator)
responded on this thread — see the highlighted reply below.
Summary:
Implement a /cost command in OpenAI Codex, modeled after the similar command in Claude Code. This command should display a summary of resource usage and changes for the current session.
Description
When a user runs /cost, the CLI should output a summary containing:
- Total cost of the session so far (in USD)
- Total API duration
- Total wall-clock duration
- Total code changes (number of lines added, removed, and net change)
The output should be formatted similarly to:
/cost
⎿ Total cost: $0.1524
⎿ Total duration (API): 23.7s
⎿ Total duration (wall): 1m 0.1s
⎿ Total code changes: 0 lines added, 0 lines removed
Acceptance Criteria
- [ ] Add a
/costcommand to the Codex CLI. - [ ] Command outputs a formatted summary as shown above.
- [ ] Tracks and displays the total cost of API calls made during the session.
- [ ] Shows total duration spent using the API (aggregated).
- [ ] Displays real (wall-clock) session duration.
- [ ] Tracks and reports all code changes, including lines added and removed.
- [ ] No actual code changes should be made directly by this command.
- [ ] Proper error handling for cases when any summary data is missing.
Notes
- Use the Claude Code
/costcommand output as a reference for the user interface. - The feature should only display information; it does not modify state.
- Please ensure performance impact is minimal when collecting and reporting data.
9 Comments
Thank you for the detailed feature request and notes, @easong-openai is working on a first version of this and that should land shortly. Then we can look at who implements further features on top of that!
@banteg kinda a workaround... I just stumbled on the Logs, has the list of completion requests and you can click into each to see # tokens.
Implementation is pending in https://github.com/openai/codex/pull/322
+1
any updates on this?
Thanks for the feedback! We're primarily focused on the native/Rust implementation of Codex CLI and would love to see if this is still an issue on the latest version. If it is, we're happy to take a look at a feature request for the
codex-rs/implementation.This shouldn't be considered completed 🤔
@codex-maintainers This should be re-opened, as it is still relevant in the new Rust CLI as well.
@codex-maintainers @easong-openai Can I pick up this issue?