Adding Accounts
Add new accounts through the OAuth browser flow:Complete browser authentication
Your default browser will open to
http://127.0.0.1:1455/auth/callback to authenticate with ChatGPT. Complete the OAuth flow in the browser window.The OAuth callback server runs on port
1455 at 127.0.0.1. If this port is already in use, stop the conflicting process before attempting login.Viewing Accounts
List all accounts in your pool with their current status:- Account index (for switching)
- Email address (case-insensitive deduplication)
- Health score (0-100)
- Active status
- Last used timestamp
Switching Accounts
Switch to a different account by index:Account Health Checks
Verify account health and token validity:Quick Health Check
- Token expiration status (with 60-second refresh skew window)
- Refresh token validity
- Account reachability
Live Forecast
Check real-time quota availability for a specific model:- 5-hour quota window status
- 7-day quota window status
- Recommended account selection
Comprehensive Diagnostics
- Health scores for all accounts
- Flagged accounts (expired/invalid tokens)
- Configuration conflicts
- Storage path validation
Account Health Scoring
Accounts are scored from 0-100 based on:| Event | Health Impact |
|---|---|
| Successful request | Health restored to 100 |
| Network error (5xx) | Health decremented, cooldown applied (6s default) |
| Rate limit hit | Health decremented, cooldown applied |
| Token refresh failure | Account marked unhealthy |
| Token expiration | Account flagged, requires re-login |
- Higher health scores
- Available quota (5-hour and 7-day windows)
- No active cooldown periods
Session Affinity
By default, session affinity keeps you on the same account for a conversation:- TTL: 20 minutes (configurable via
sessionAffinityTtlMs) - Max entries: 512 conversations tracked
- Behavior: Reuses the same account for a session ID unless health degrades
Proactive Token Refresh
The Proactive Refresh Guardian automatically refreshes tokens before expiration:- Check interval: 60 seconds (default)
- Buffer window: 5 minutes before expiration
- Background operation: Runs independently of active requests
Fixing Unhealthy Accounts
When accounts become unhealthy due to expired tokens or connectivity issues:Common Token Errors
| Error | Cause | Solution |
|---|---|---|
missing field id_token | Stale auth payload | Re-login the account |
refresh_token_reused | Token pair rotated elsewhere | Re-login the account |
token_expired | Refresh token no longer valid | Re-login the account |
All accounts unhealthy | Entire pool stale | Run codex auth doctor --fix, then add a fresh account |
Per-Project Accounts
By default (perProjectAccounts: true), accounts are stored per-project:
- Global accounts:
~/.codex/multi-auth/openai-codex-accounts.json - Project accounts:
~/.codex/multi-auth/projects/<project-key>/openai-codex-accounts.json
Worktree Support
Linked Git worktrees share accounts viaresolveProjectStorageIdentityRoot:
- Plugin detects
.gitfile in worktree - Reads
gitdirpointer to resolve the main repository - Uses the main repository’s project key for account storage
- Legacy worktree-keyed accounts are auto-migrated on first load
Legacy worktree-specific account files are retained on migration only if the canonical write fails (to prevent data loss).
Removing Accounts
To remove an account from the pool:Email Deduplication
Account email addresses are deduplicated usingnormalizeEmailKey() (trim + lowercase):
[email protected]and[email protected]are treated as the same account- Re-login with the same email updates the existing account instead of creating a duplicate
Monitoring and Reporting
Generate comprehensive account reports:- Account pool snapshot
- Live quota status for all accounts
- Health scores and cooldown timers
- Flagged accounts requiring attention
- Configuration effective values