@solly922/opencode-codex-multiauth is an OpenCode plugin that lets you use multiple ChatGPT OAuth accounts with the ChatGPT Codex backend and rotate between them automatically.
This project builds on work from:
guard22-multiauth: https://github.com/guard22/opencode-multi-auth-codexcrim50n-multiauth: https://github.com/crim50n/opencode-multi-auth-codex
- Rotate across multiple ChatGPT OAuth accounts
- Keep using the ChatGPT Codex backend with Codex-style headers and request mapping
- Add accounts through browser OAuth or headless device auth
- Manage accounts from a localhost dashboard
- Pin traffic to a single account with force mode
- Track rate limits, cooldowns, invalid auth, and unsupported models
- Use weighted or health-based rotation strategies
- Sync with Codex
auth.json
- Multi-account account store with migration support
- Browser OAuth and headless device auth
- ChatGPT Codex backend forwarding
- Local dashboard for account management and runtime settings
- Rotation strategies:
round-robinleast-usedrandomweighted-round-robin
- Force mode
- Rate-limit probing and cooldown handling
- Proxy-aware auth and backend networking
- Cross-process store locking
- Node.js 20+
- npm
- OpenCode
- One or more ChatGPT accounts with Codex access
- Install the package.
- Point OpenCode at the installed plugin entry.
- Add one or more ChatGPT accounts.
- Start using OpenCode with the
openaiprovider.
npm install -g @solly922/opencode-codex-multiauthThen point OpenCode at the installed plugin entry.
Run this to get your global node_modules directory:
npm root -gThen use this file URL in OpenCode:
file://<npm-root>/@solly922/opencode-codex-multiauth/dist/index.js
Example:
file:///Users/you/.npm-global/lib/node_modules/@solly922/opencode-codex-multiauth/dist/index.js
Edit ~/.config/opencode/opencode.json:
{
"plugin": [
"file:///absolute/path/to/@solly922/opencode-codex-multiauth/dist/index.js"
]
}Restart OpenCode after updating the config.
git clone https://github.com/solly922/opencode-codex-multiauth.git codex-multiauth
cd codex-multiauth
npm ci
npm run buildThen use the built entry at file:///absolute/path/to/codex-multiauth/dist/index.js in the same OpenCode config shown above.
You can add accounts from either the OpenCode UI or the CLI.
- Open auth/provider settings for
openai - Select
ChatGPT OAuth (Multi-Account) - Enter an alias such as
personal,work, orbackup - Complete the browser login flow
Headless option:
ChatGPT OAuth (Headless, Multi-Account)uses a device-style auth flow instead of opening a callback browser flow.
Primary CLI name:
codex-multiauth add personal
codex-multiauth add work --headless
codex-multiauth list
codex-multiauth status
codex-multiauth remove backup
codex-multiauth pathCompatibility alias:
opencode-multi-auth statuscodex-multiauth web --host 127.0.0.1 --port 3434Open http://127.0.0.1:3434 in your browser.
The dashboard is loopback-only and includes:
- account list and health state
- active account display
- enable/disable toggles
- force mode controls
- re-auth actions
- runtime settings updates
- rate-limit refresh/probing
- sync status
Once the plugin is loaded and you have accounts configured:
- Use the
openaiprovider in OpenCode - Choose a Codex-compatible model
- Send requests normally
The plugin will:
- select an eligible account
- attach Codex-style headers such as
chatgpt-account-id,OpenAI-Beta, andoriginator - forward the request to
https://chatgpt.com/backend-api - rotate away from invalid, rate-limited, or temporarily unsupported accounts
- Account store:
~/.config/opencode/codex-multiauth-accounts.json - Codex auth file:
~/.codex/auth.json - Logs:
~/.config/opencode/codex-multiauth/logs/codex-multiauth.log
OPENCODE_MULTI_AUTH_STORE_FILE: override the account store pathOPENCODE_MULTI_AUTH_CODEX_AUTH_FILE: override the Codex auth file pathCODEX_MULTIAUTH_LOG_PATH: override the log file pathOPENCODE_MULTI_AUTH_PROXY_URL: force a proxy for auth/backend trafficHTTP_PROXY,HTTPS_PROXY,ALL_PROXY,NO_PROXY: standard proxy environment variablesOPENCODE_MULTI_AUTH_SYNC_OPENCODE_AUTH=1: import OpenCode's currentopenaiOAuth session into the plugin account poolOPENCODE_MULTI_AUTH_MODEL_INJECTION=auto|latest|default|opencode: control whether the plugin preserves OpenCode's model list, injects only the latest model, or injects the full plugin model setOPENCODE_MULTI_AUTH_INJECT_MODELS=0: disable runtime model injectionOPENCODE_MULTI_AUTH_STRIP_ITEM_REFERENCES=0: stop strippingitem_referenceinputs before forwardingOPENCODE_MULTI_AUTH_PREFER_CODEX_LATEST=1: map older Codex selections to the configured latest model
- Force mode pins traffic to one alias until cleared or expired.
- Dashboard settings affect runtime rotation behavior.
- Forwarded requests keep
store: false. - Browser auth and backend traffic are proxy-aware.
- OpenCode auth-session syncing is disabled by default; enable it only if you want the plugin to import your current OpenCode
openailogin automatically. - Model injection defaults to
auto: preserve OpenCode's existing OpenAI model list when it already exists, otherwise seed the provider with the plugin's default Codex-compatible models. - The merged implementation preserves the ChatGPT Codex backend forwarding behavior that made the earlier
crim50nfork reliable in practice.
- Make sure
npm run buildsucceeded - Verify the
pluginentry points todist/index.js - Restart OpenCode after editing
opencode.json
codex-multiauth status
codex-multiauth listThen check whether the accounts are disabled, rate-limited, auth-invalid, or currently pinned by force mode.
- Make sure your machine can accept loopback callbacks on
127.0.0.1 - Retry with
--headless - Check whether your proxy settings are interfering with auth traffic
- Use the dashboard from the same local origin it was started on
- Mutating endpoints are same-origin protected and loopback-only by design
- The canonical log path is now
~/.config/opencode/codex-multiauth/logs/codex-multiauth.log - The canonical systemd user service name is now
codex-multiauth.service - The old
CODEX_SOFT_LOG_PATHenv var is still accepted as a fallback
npm run build
npm run lint
npm run test:unit
npm run test:integration
npm run test:web:headless
npm run test:sandboxOPENCODE_SETUP_1TO1.mdcodextesting.mddocs/