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:- OAuth API (Recommended)
- CLI RPC
- CLI PTY (Fallback)
- Web Dashboard (Optional)
OAuth API
The OAuth API is the preferred method for the app when credentials are available.Setup:- Authenticate with Codex CLI:
codex auth login - OAuth tokens are automatically saved to
~/.codex/auth.json - CodexBar reads these credentials automatically
- Endpoint:
GET https://chatgpt.com/backend-api/wham/usage - Authentication:
Authorization: Bearer <access_token> - Token refresh: Automatic when older than 8 days
- Rate limits (5-hour and weekly windows)
- Credits balance and unlimited status
- Account identity (email + plan type)
Data Source Selection
App Default (Debug Menu Disabled)
- OAuth API (if
~/.codex/auth.jsonexists) - CLI RPC, with CLI PTY fallback
- If OpenAI cookies enabled, dashboard extras load in parallel (source becomes
primary + openai-web)
CLI Default (--source auto)
- OpenAI web dashboard (when available)
- 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/...ifCODEX_HOMEis set
- Parses
event_msgtoken_count entries andturn_contextmodel 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
- Settings → General → Show cost summary
- Menu shows “Cost (30d): $X.XX” below usage meters
Account Identity Resolution
CodexBar determines your Codex account from:- Latest Codex usage snapshot (from RPC)
~/.codex/auth.json(JWT claims: email + plan)- OpenAI dashboard signed-in email (cached)
- 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
OAuth token expired
OAuth token expired
CodexBar automatically refreshes tokens older than 8 days. If refresh fails:
- Run
codex auth loginto re-authenticate - Restart CodexBar
CLI RPC connection failed
CLI RPC connection failed
Check that Codex CLI is installed and authenticated:If not authenticated, run
codex auth login.Web dashboard shows 'Login required'
Web dashboard shows 'Login required'
- Visit https://chatgpt.com/codex/settings/usage in your browser
- Log in with your OpenAI account
- Return to CodexBar and click “Refresh”
CLI update needed
CLI update needed
CodexBar detects when the CLI has an available update:
Keychain prompts for auth.json
Keychain prompts for auth.json
If OAuth credentials are stored in Keychain (non-standard), you may see prompts.
To avoid this:
- Open Keychain Access.app
- Search for “Codex” or “OpenAI”
- Open the item → Access Control
- Add CodexBar.app to “Always allow access by these applications”
CLI Usage
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/*
Related Documentation
- Codex OAuth Details - OAuth implementation specifics
- CLI Reference - CLI usage and options
- Provider Authoring - How providers work internally
