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 /cost command 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 /cost command 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.

View original on GitHub ↗

9 Comments

tibo-openai collaborator · 1 year ago

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!

g0t4 · 1 year ago

@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.

tibo-openai collaborator · 1 year ago

Implementation is pending in https://github.com/openai/codex/pull/322

crabsinger · 1 year ago

+1

VictorAndresDlh · 1 year ago

any updates on this?

codex-maintainers · 11 months ago

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.

VVsxmja · 9 months ago

This shouldn't be considered completed 🤔

0xdevalias · 9 months ago

@codex-maintainers This should be re-opened, as it is still relevant in the new Rust CLI as well.

Aki-07 · 9 months ago

@codex-maintainers @easong-openai Can I pick up this issue?