Skip to content

Show local Codex session costs for organization API-key users #2174

Description

@wicolian

Problem

CodexBar can display account-level Codex quota data through managed accounts, OAuth, CLI, or optional OpenAI web access. Developers who use Codex with an organization-provided API key often cannot access organization billing or usage views because those require administrator permissions.

Codex itself writes local JSONL session records that include the final token ledger for each conversation. CodexBar can use those records to provide a local API-rate estimate without an Admin API key or a billing API request.

Expected behavior

  • Keep the selected managed Codex account available for its normal account and quota flows.
  • Independently scan $CODEX_HOME/sessions when set, otherwise ~/.codex/sessions.
  • Show local 1-day and 30-day token and estimated-cost totals.
  • Show conversation and model breakdowns behind those totals.
  • Do not present a failed remote quota refresh as a failed local cost estimate.

Local data source

For a session file, the final ledger is the last token_count record:

rg '"type":"token_count"' \
  ~/.codex/sessions/2026/07/14/rollout-2026-07-14T16-38-08-<session>.jsonl \
  | tail -1

The estimator separates cached from uncached input before applying the configured model rates. The displayed amount is an API-rate estimate, not an organization invoice. Negotiated pricing, credits, and taxes can differ.

Privacy

This uses session files already stored locally. It does not upload session content, call the OpenAI billing API, or require administrator access.

Proposed fix

Implemented by PR #2172.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions