opencode-openai-codex-multi-auth
v4.5.24
Published
OpenAI ChatGPT (Codex backend) OAuth auth plugin for opencode - use your ChatGPT Plus/Pro subscription instead of API credits
Maintainers
Readme
Fork maintained by iam-brain.
Upstream project (credit): numman-ali/opencode-openai-codex-auth
One install. Every Codex model. Multi-account aware. Install · Models · Configuration · Docs
NOTE:
Currently, the CLI (opencode auth login) path does not work correctly due to a possibly unintentional bug in how Opencode handles provider logins in their CLI. The TUI (opencode > ctrl + x m > ctrl + a, OpenAI) path works perfectly as it functions as intended.
Related issue: Issue #10898
Related PRs: Pull #11058 // Pull #11076
💡 Philosophy
"One config. Every model." OpenCode should feel effortless. This plugin keeps the setup minimal while giving you full GPT‑5.x + Codex access via ChatGPT OAuth.
┌─────────────────────────────────────────────────────────┐
│ │
│ ChatGPT OAuth → Codex backend → OpenCode │
│ One command install, full model presets, done. │
│ │
└─────────────────────────────────────────────────────────┘🚀 Quick Start
npx -y opencode-openai-codex-multi-auth@latestThen:
opencode auth login
opencode run "write hello world to test.txt" --model=openai/gpt-5.2 --variant=mediumLegacy OpenCode (v1.0.209 and below):
npx -y opencode-openai-codex-multi-auth@latest --legacy
opencode run "write hello world to test.txt" --model=openai/gpt-5.2-mediumUninstall:
npx -y opencode-openai-codex-multi-auth@latest --uninstall
npx -y opencode-openai-codex-multi-auth@latest --uninstall --all⚠️ Migration Note (Multi-Plan Accounts)
If you used multiple plans or emails under the same ChatGPT accountId on older versions, the previous matching logic could overwrite entries. To regenerate a clean layout:
rm ~/.config/opencode/openai-codex-accounts.json
opencode auth login📦 Models
- gpt-5.2 (none/low/medium/high/xhigh)
- gpt-5.2-codex (low/medium/high/xhigh)
- gpt-5.1-codex-max (low/medium/high/xhigh)
- gpt-5.1-codex (low/medium/high)
- gpt-5.1-codex-mini (medium/high)
- gpt-5.1 (none/low/medium/high)
🧩 Configuration
- Modern (OpenCode v1.0.210+):
config/opencode-modern.json - Legacy (OpenCode v1.0.209 and below):
config/opencode-legacy.json
Minimal configs are not supported for GPT‑5.x; use the full configs above.
⌨️ Slash Commands (TUI)
In the OpenCode TUI, you can use these commands to manage your accounts and monitor usage:
| Command | Description |
|---------|-------------|
| /codex-status | Shows current rate limits (5h/Weekly), credits, and account status (percent left). |
| /codex-switch-accounts <index> | Switch the active account by its 1-based index from the status list. |
| /codex-toggle-account <index> | Enable or disable an account by its 1-based index (prevents auto-selection). |
✅ Features
- ChatGPT Plus/Pro OAuth authentication (official flow)
- 22 model presets across GPT‑5.2 / GPT‑5.2 Codex / GPT‑5.1 families
- Variant system support (v1.0.210+) + legacy presets
- Multimodal input enabled for all models
- Usage‑aware errors + automatic token refresh
- Multi-account support with sticky selection + PID offset (great for parallel agents)
- Account enable/disable management (via
opencode auth loginmanage) - Strict account identity matching (
accountId+email+plan) - Hybrid account selection strategy (health score + token bucket + LRU bias)
- Optional round-robin account rotation (maximum throughput)
- OpenCode TUI toasts +
codex-status/codex-switch-accountstools - Authoritative Codex Status: Real-time rate limit monitoring (5h/Weekly) with ASCII status bars
📚 Docs
- Getting Started:
docs/getting-started.md - Configuration:
docs/configuration.md - Multi-Account:
docs/multi-account.md - Troubleshooting:
docs/troubleshooting.md - Architecture:
docs/development/ARCHITECTURE.md
⚠️ Usage Notice
This plugin is for personal development use with your own ChatGPT Plus/Pro subscription. For production or multi‑user applications, use the OpenAI Platform API.
Credits
- Original implementation and ongoing upstream work: Numman Ali and contributors (
numman-ali/opencode-openai-codex-auth) - Multi-account strategy + UX inspiration (rotation modes, PID offset approach, toasts): NoeFabris and contributors (
NoeFabris/opencode-antigravity-auth) - This fork: multi-account pool, sticky-by-default rotation with PID offset, round-robin option, and account tools/toasts
Built for developers who value simplicity.
