Switch between saved OpenAI OAuth accounts inside OpenCode with a native TUI dialog through /switch-codex.
Recommended:
opencode plugin -g opencode-codex-switchManual install:
For a global manual install, add the plugin to both ~/.config/opencode/opencode.json and ~/.config/opencode/tui.json.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-codex-switch"]
}~/.config/opencode/tui.json
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["opencode-codex-switch"]
}The add-account flow uses OpenCode's built-in OpenAI/Codex OAuth methods.
Open the account switcher with either:
/switch-codex- Command palette ->
Switch Codex Account
Inside the dialog:
Enterswitches to the selected saved accountastarts OpenCode's OpenAI/Codex OAuth flow to add another accountCtrl+Ddeletes the selected saved account
Each row shows the account email when available, and falls back to the OpenAI account ID when email is unavailable.
The plugin has two parts that work together:
- Server plugin: intercepts
/switch-codexand forwards it to the TUI command - TUI plugin: renders the account picker and handles switching, adding, and deleting accounts through OpenCode's built-in OAuth flow
Saved accounts are stored in the local OpenCode data directory and the active account is applied through OpenCode's auth client when you switch.
- OpenAI-only: this plugin is currently built for OpenAI OAuth account switching
- Local storage: saved accounts are written to OpenCode's local data directory
- Browser required for add-account: adding a new account uses OpenCode's OpenAI/Codex OAuth browser flow
MIT