Codex OAuth account fallback orchestrator. CAO keeps separate CODEX_HOME directories per account and automatically falls back to the next account when quota is exhausted.
Language: English | 한국어 | 日本語 | 中文 | Español
CAO focuses on long-running Codex sessions, resilience, and visibility.
- Automatic fallback on quota exhaustion
- Gateway mode for seamless account switching without session drops
- Health checks and compact status summaries
- Shareable Markdown or JSON reports
- Per-account isolation with separate
CODEX_HOMEdirectories
- Node.js 18+
- Codex CLI installed and available on
PATH
npm install -g codex-account-orchestratorThe CLI is available as cao (alias) or codex-account-orchestrator.
- Add accounts
cao add accountA
cao add accountB- Select the default account
cao switch- Run with fallback
cao runTo pass arguments to Codex, put them after --:
cao run -- exec "summarize README"| Command | Description |
|---|---|
cao add <name> |
Add an account and log in |
cao switch |
Interactive account switch |
cao current |
Show current default account |
cao list |
List accounts (quick) |
cao status |
Status dashboard (TTY) or compact summary |
cao status --full |
Full verbose status |
cao status --compact |
One-line summaries |
cao status --doctor |
Health checks and exit codes |
| `cao status --report [md | json]` |
cao run |
Run with fallback |
cao run --gateway |
Route through gateway |
cao status # pretty dashboard in TTY, compact otherwise
cao status --full # verbose multi-line output
cao status --compact # one-line summaries
cao status --pretty # force the dashboard viewHealth checks with exit codes (0=ok, 1=warn, 2=error):
cao status --doctor
cao status --doctor --jsonShareable reports:
cao status --report # Markdown report
cao status --report json # JSON reportGateway mode keeps the Codex session open while switching accounts on quota errors.
Start the gateway:
cao gateway startOn macOS, cao gateway start also exports OPENAI_BASE_URL via launchctl (so the Codex desktop app can route through the gateway when launched from Dock/Finder). You can disable this with:
cao gateway start --no-app-envRun Codex through the gateway (CLI fallback disabled):
cao run --gatewayEnable routing for Codex:
cao gateway enableDisable routing:
cao gateway disableEach account lives under its own directory:
~/.codex-account-orchestrator/<account>/
config.toml is created per account:
cli_auth_credentials_store = "file"
forced_login_method = "chatgpt"On quota errors, CAO re-runs Codex with the next account and can recheck all accounts for multiple passes.
~/.codex-account-orchestrator/
registry.json
account_status.json
<account>/auth.json
<account>/config.toml
If you have snapshots from other tools, import them:
cao import codex-auth
cao import codex-auth --source ~/.codex/accounts
cao import codex-auth --overwritenpm install
npm run test- Fallback captures output and may look like a non-TTY to Codex. Use
--no-fallbackif you want a pure TTY session. - The quota detector is keyword-based and can be extended in
src/constants.ts.
See CHANGELOG.md for release notes.