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-go-multi-auth

v0.1.2

Published

Multi-account API key rotation for OpenCode Go subscription

Downloads

393

Readme

opencode-go-multi-auth

Multi-account API key rotation for OpenCode Go subscription.

Run multiple OpenCode Go accounts side-by-side. The plugin picks one account per OpenCode process (not per subagent/task) and sticks with it. When you hit Go's rate limit (HTTP 429), it automatically fails over to the next account.

License GitHub last commit


Features

  • Multi-account rotation — Spread your usage across several Go API keys.
  • Per-process account stickiness — One account per OpenCode process. Quit and reopen to rotate. New subagents and tasks reuse the same account.
  • Automatic 429 failover — When the active account is rate-limited, the plugin transparently retries with the next account.
  • CLI account management — Add, list, remove, and inspect accounts from the terminal.
  • Persistent state — Accounts and rotation position survive restarts.
  • No modifications to OpenCode — Installs as a plugin, zero risk to your existing setup.

Installation

opencode plugin github:masrurimz/opencode-go-multi-auth --global

This installs the plugin globally so every OpenCode session uses it.

Prerequisites:


Quick Start

1. Get your Go API keys

Open opencode.ai/auth in your browser and generate one or more Go subscription API keys. Copy each key to your clipboard.

2. Add an account to the plugin

In OpenCode, open the auth settings and run the Add Go Account method:

OpenCode Settings → Auth → Add Go Account

Paste your Go API key when prompted. Optionally give it a label (e.g. "Work", "Personal", "Account 2").

Repeat for each Go subscription you own.

3. Start using OpenCode

That's it. The plugin automatically picks an account on every session start and signs all requests with its API key. OpenCode will show "opencode" as the active auth provider.


Commands

| Method | Label | Purpose | |---|---|---| | api | Add Go Account | Add a new Go API key to the rotation pool | | oauth | Manage Accounts | List all accounts and remove unwanted ones | | oauth | View Account Status | Show account list, status, and rotation position |

Access these from OpenCode's auth settings panel.


How Rotation Works

  1. OpenCode process starts — The plugin loads all configured accounts and picks the next one in round-robin order (tracked in ~/.config/opencode/opencode-go-rotation.json).
  2. Per-process stickiness — The same account is used for every request during the process lifetime. All subagents, tasks, and conversations share the same account. This preserves token caches.
  3. On 429 (rate limit) — The plugin marks the current account as exhausted, switches to the next enabled account, and retries the request. If all accounts are exhausted, it returns a 429 response.
  4. Next process — Quit and reopen OpenCode. The rotation index advances, so the new process gets a different account.

See docs/quota-rotation.md for details.


Storage

Accounts and rotation state live in ~/.config/opencode/:

| File | Purpose | |---|---| | opencode-go-accounts.json | Stored API keys, labels, enabled/disabled state | | opencode-go-rotation.json | Last used account index (for round-robin) |

Both files use 0o600 permissions. The accounts file is written atomically (tmp + rename). If the file becomes corrupt, a .bak.<timestamp> backup is created automatically.


Development

git clone https://github.com/masrurimz/opencode-go-multi-auth
cd opencode-go-multi-auth
bun install
bun test       # 23 tests across 4 modules
bun run build  # bundles to dist/index.mjs
bun run typecheck  # tsc --noEmit

Architecture

┌─────────────┐     ┌──────────────┐     ┌──────────┐
│   index.ts  │────▶│   storage.ts │────▶│  Disk    │
│  (Plugin)   │     │  (Accounts)  │     │ (JSON)   │
└──────┬──────┘     └──────────────┘     └──────────┘
       │
       ├──▶ rotate.ts     ── round-robin selection
       ├──▶ fetch.ts      ── auth header injection + 429 failover
       └──▶ types.ts      ── shared type definitions

See docs/architecture.md for the full breakdown.


License

MIT