opencode-openai-profiles
v0.1.5
Published
OpenCode TUI plugin for switching saved OpenAI ChatGPT OAuth profiles.
Maintainers
Readme
opencode-openai-profiles
OpenCode TUI plugin for switching between saved OpenAI ChatGPT Pro/Plus OAuth profiles.
OpenCode has one active openai auth slot. This plugin saves named copies of that auth object and swaps one into auth.json when you switch profiles.
Status
Early local-first plugin. Profile switches apply live when your OpenCode version supports runtime auth updates.
Install
Package: opencode-openai-profiles
Install globally:
opencode plugin opencode-openai-profiles@latest --globalThis installs the package and adds it to OpenCode's server and TUI plugin configs when OpenCode exposes both targets.
Manual config alternative:
{
"plugin": ["opencode-openai-profiles@latest"]
}For local development, build from this repo:
pnpm install
pnpm buildInstall the local plugin:
opencode plugin "$PWD" --global --forceUsage
Open the account picker:
/openai-profilesFor direct commands, use /openai-profiles-cli:
/openai-profiles-cli save <name>
/openai-profiles-cli switch <name>
/openai-profiles-cli rename <old> <new>
/openai-profiles-cli list
/openai-profiles-cli active
/openai-profiles-cli login [browser|headless]
/openai-profiles-cli complete <callback-url-or-code>First Setup
Save your current OpenAI account:
/openai-profilesChoose Save Current Profile, then enter account-1 or another name.
If you skip this step, the plugin saves the active unsaved account as account-1 before starting a new OpenAI login.
Log in to another account:
/openai-profilesChoose Login to OpenAI. Select ChatGPT Pro/Plus (headless) if you want to paste the final callback URL by hand.
Direct command:
/openai-profiles-cli login browser
/openai-profiles-cli login headlessFor direct headless login, open the returned URL, copy the final callback URL from the browser address bar, then run:
/openai-profiles-cli complete <callback-url-or-code>If OpenCode prompts you to restart after login, restart it before saving the new active account:
/openai-profilesChoose Save Current Profile, then enter account-2 or another name.
Switch profiles:
/openai-profilesChoose Switch Profile, then select a saved profile.
If OpenCode cannot apply the switch live, the plugin will tell you to restart.
Direct command:
/openai-profiles-cli switch account-1
/openai-profiles-cli switch account-2Storage
OpenCode stores the active auth file here:
~/.local/share/opencode/auth.jsonThis plugin stores saved OpenAI profiles here:
~/.local/share/opencode/auth-profiles/Example files:
openai-account-1.json
openai-account-2.jsonEach profile file contains only the openai OAuth object. The plugin preserves other providers in auth.json.
Security
Profile files contain OAuth tokens. Treat them as secrets.
Do not commit auth.json or auth-profiles.
The plugin never displays token values. It only shows the OpenAI accountId when available.
