Skip to main content
The Codex provider tracks usage for OpenAI’s Codex coding assistant, supporting multiple authentication methods with automatic fallback.

Features

  • Session (5-hour) and weekly rate limit tracking
  • Credits balance monitoring
  • Local token cost analysis from session logs
  • Optional OpenAI web dashboard extras (usage charts, credits history)
  • Status page integration with OpenAI incidents

Authentication Methods

CodexBar supports three primary authentication methods for Codex:

Data Source Selection

App Default (Debug Menu Disabled)

  1. OAuth API (if ~/.codex/auth.json exists)
  2. CLI RPC, with CLI PTY fallback
  3. If OpenAI cookies enabled, dashboard extras load in parallel (source becomes primary + openai-web)

CLI Default (--source auto)

  1. OpenAI web dashboard (when available)
  2. Codex CLI RPC, with CLI PTY fallback

Manual Override

Preferences → Providers → Codex → Usage source:
  • Auto - Uses the default selection above
  • OAuth - Forces OAuth API only
  • CLI - Forces CLI RPC/PTY only

Local Cost Usage

CodexBar scans local session logs to compute token costs: Source files:
  • ~/.codex/sessions/YYYY/MM/DD/*.jsonl
  • ~/.codex/archived_sessions/*.jsonl
  • Or $CODEX_HOME/sessions/... if CODEX_HOME is set
Scanner behavior:
  • Parses event_msg token_count entries and turn_context model markers
  • Computes input/cached/output token deltas and per-model cost
  • Cached in ~/Library/Caches/CodexBar/cost-usage/codex-v1.json
  • Window: last 30 days (rolling), 60s minimum refresh interval
View cost summary:
  1. Settings → General → Show cost summary
  2. Menu shows “Cost (30d): $X.XX” below usage meters

Account Identity Resolution

CodexBar determines your Codex account from:
  1. Latest Codex usage snapshot (from RPC)
  2. ~/.codex/auth.json (JWT claims: email + plan)
  3. OpenAI dashboard signed-in email (cached)
  4. Last imported browser cookie email (cached)

Status Page Integration

CodexBar monitors OpenAI Status for incidents:
  • Polls Statuspage.io API every 5 minutes (configurable)
  • Displays incident badge on menu bar icon
  • Shows incident details in menu
  • Click “View Status” to open status page

Troubleshooting

CodexBar automatically refreshes tokens older than 8 days. If refresh fails:
  1. Run codex auth login to re-authenticate
  2. Restart CodexBar
Check that Codex CLI is installed and authenticated:
codex --version
codex /status
If not authenticated, run codex auth login.
  1. Visit https://chatgpt.com/codex/settings/usage in your browser
  2. Log in with your OpenAI account
  3. Return to CodexBar and click “Refresh”
CodexBar detects when the CLI has an available update:
npm update -g @openai/codex-cli
If OAuth credentials are stored in Keychain (non-standard), you may see prompts. To avoid this:
  1. Open Keychain Access.app
  2. Search for “Codex” or “OpenAI”
  3. Open the item → Access Control
  4. Add CodexBar.app to “Always allow access by these applications”

CLI Usage

# Show Codex usage
codexbar --provider codex
codexbar -p codex

# Force specific source
codexbar -p codex --source oauth
codexbar -p codex --source cli

# Show cost summary
codexbar cost --provider codex

Key Files

  • OAuth: Sources/CodexBarCore/Providers/Codex/CodexOAuthFetcher.swift
  • Web dashboard: Sources/CodexBarCore/OpenAIWeb/*
  • CLI RPC/PTY: Sources/CodexBarCore/Providers/Codex/CodexStatusProbe.swift
  • Cost usage: Sources/CodexBarCore/CostUsageFetcher.swift, Sources/CodexBarCore/Vendored/CostUsage/*

Build docs developers (and LLMs) love