@narumitw/pi-codex-accounts
v0.14.1
Published
Pi extension for switching self-managed ChatGPT Codex subscription accounts without touching /login.
Maintainers
Readme
🔐 pi-codex-accounts — Codex Account Switcher for Pi
@narumitw/pi-codex-accounts is a native Pi coding agent extension that lets you log in to, switch between, and remove multiple ChatGPT Plus/Pro Codex subscription accounts.
It keeps using Pi's built-in openai-codex provider. It does not add provider aliases, register OAuth providers, or change Pi's built-in /login and /logout provider lists.
✨ Features
- Adds
/codex-login <name>for storing a named ChatGPT Codex subscription account. - Adds
/codex-account [name]for switching the active self-managed Codex account. - Adds
/codex-logout <name>for deleting one self-managed account. - Adds
(default pi login)in the selector to clear the active self-managed account and return to Pi's normalopenai-codexauth. - Stores credentials in
~/.pi/agent/codex-accounts.jsonwith private file permissions. - Sets only the runtime API key for Pi's native
openai-codexprovider. - Leaves your selected
/modelunchanged, matching Pi's built-in/loginbehavior, except it may selectopenai-codex/gpt-5.5when the current model isunknown/unknown. - Shows
codex:<name>in the statusline only while the current model provider isopenai-codex. - Fails closed if an active self-managed account cannot refresh, so Pi does not silently fall back to a different Codex account.
- Closes the current session's cached Codex WebSocket when auth changes, preventing a reused connection from staying on the previous account.
📦 Install
pi install npm:@narumitw/pi-codex-accountsTry without installing permanently:
pi -e npm:@narumitw/pi-codex-accountsTry this package locally from the repository root:
pi -e ./extensions/pi-codex-accounts🚀 Usage
Login to named accounts:
/codex-login work
/codex-login personalSwitch accounts:
/codex-account
/codex-account workReturn to Pi's built-in Codex login without deleting any self-managed account:
/codex-account defaultRemove one self-managed account:
/codex-logout work🔐 Auth behavior
When an active self-managed account is set, the extension applies that account's access token as Pi's runtime key for the native openai-codex provider.
When no self-managed account is active, the extension removes its runtime override and Pi uses its normal openai-codex auth resolution. That means existing /login openai-codex, auth.json, or environment behavior still works.
If the active self-managed account refresh fails, the extension keeps a non-empty failing runtime key in place. This prevents accidental fallback to a different Codex account.
Account switches and token refreshes also close any cached Codex WebSocket for the current Pi session. The next request reconnects with the newly selected credentials; repeated pre-turn checks, including turns started after compaction, keep the connection when auth is unchanged.
🚧 Limitations
- This extension supports ChatGPT Plus/Pro Codex subscription auth only.
- It does not rotate accounts automatically or try to bypass rate limits.
- It does not switch Claude, Anthropic, or browser-cookie sessions.
- Multiple Pi processes refreshing the same account at the same time are serialized through Pi's auth-file lock helper, but the newest refreshed token wins.
🗂️ Package layout
extensions/pi-codex-accounts/
├── src/
│ └── codex-accounts.ts
├── test/
│ └── codex-accounts.test.ts
├── README.md
├── LICENSE
├── tsconfig.json
└── package.jsonThe package exposes its Pi extension through package.json:
{
"pi": {
"extensions": ["./src/codex-accounts.ts"]
}
}🔎 Keywords
Pi extension, Pi coding agent, Codex, ChatGPT Plus, ChatGPT Pro, subscription account switching, OAuth.
📄 License
MIT. See LICENSE.
