npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-openai-sub-switcher

v1.0.7

Published

Multi-account OpenAI authentication plugin for OpenCode. Supports multiple ChatGPT Plus/Pro accounts with easy switching.

Downloads

585

Readme

opencode-openai-sub-switcher

OpenCode plugin for saving and switching between multiple OpenAI OAuth subscriptions that OpenCode already authenticated.

It does not replace OpenCode auth. It snapshots the current openai auth entry from OpenCode, stores multiple saved variants locally, and restores one when you switch.

Install

npm install -g opencode-openai-sub-switcher
opencode-openai-sub-switcher-install

Then fully restart OpenCode.

No plugin entry in opencode.json is required. The installer writes a local wrapper file into ~/.config/opencode/plugins/, and OpenCode auto-loads plugins from that directory.

Files installed

  • ~/.config/opencode/plugins/opencode-openai-sub-switcher.ts
  • ~/.config/opencode/commands/switch-sub.md
  • ~/.config/opencode/commands/list-subs.md
  • ~/.config/opencode/commands/save-sub.md
  • ~/.config/opencode/commands/rename-sub.md
  • ~/.config/opencode/commands/remove-sub.md

Uninstall

opencode-openai-sub-switcher-uninstall

Quick Start

  1. Log into OpenCode with OpenAI normally.
  2. Run /save-sub to save the current OpenAI snapshot.
  3. Run /switch-sub to switch to another saved subscription.
  4. Repeat /save-sub whenever you want to keep a newly logged-in subscription.

Demo

Typical flow:

/save-sub
/connect
/save-sub
/list-subs
/switch-sub

Example result:

Saved accounts:
- d*****r@o*****k.com (team)
- d*****r@o*****k.com (plus)
- d*****[email protected] (team) *

The * marks the currently active OpenAI snapshot.

Slash Commands

  • /switch-sub - switch to another saved OpenAI subscription
  • /list-subs - list saved subscriptions
  • /save-sub - save the current OpenCode OpenAI auth snapshot
  • /rename-sub - rename a saved subscription
  • /remove-sub - remove a saved subscription

These commands use the plugin tools under the hood and ask short follow-up questions when needed.

CLI

Save current account:

opencode-openai-sub-switcher add

List saved accounts:

opencode-openai-sub-switcher list

Switch by saved id:

opencode-openai-sub-switcher switch <id>

Rename or remove:

opencode-openai-sub-switcher rename <id> "Work"
opencode-openai-sub-switcher remove <id>

OpenCode Tools

The plugin also exposes these tools inside OpenCode:

  • list_openai_accounts
  • save_current_openai_account
  • switch_openai_account
  • rename_openai_account
  • remove_openai_account

How It Works

  • Snapshots are stored in ~/.opencode/multi-openai-accounts.json with 0600 permissions.
  • Only the openai subtree is restored into ~/.local/share/opencode/auth.json.
  • Other providers in auth.json are preserved.
  • OpenCode continues to own login and token refresh.
  • The plugin only stores, lists, renames, removes, and restores saved OpenAI snapshots.
  • Listing, switching, and startup do not auto-save credentials. Saving is explicit via /save-sub or CLI add.

Identity Model

Saved entries are deduplicated by accountId + sub.

That means:

  • same OpenAI subscription and same identity updates the existing saved entry
  • same OpenAI subscription but different identity can be saved as a separate entry

Privacy

  • CLI and tool output is redacted by default.
  • Raw auth snapshots stay local and unmodified so switching still works.

Disable redaction locally if you want full output:

export OPENCODE_OPENAI_SUB_SWITCHER_REDACT=false

Security Notes

  • Removed automatic backup recovery for deleted snapshots, so removed entries are not retained in a .bak file.
  • Uninstall also removes the local snapshot registry files from ~/.opencode/.
  • Raw tokens are still stored locally, unencrypted, with 0600 file permissions.

Accepted false values:

  • false
  • 0
  • off
  • no

Troubleshooting

If slash commands do not appear:

  1. Run opencode-openai-sub-switcher-install again.
  2. Fully quit OpenCode.
  3. Reopen OpenCode.

If a new login does not create a new saved entry:

  • it likely resolved to the same accountId + sub as an existing saved entry
  • logins only become separate saved entries when that identity key differs

License

MIT