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

anthropic-multi-auth

v0.1.1

Published

Multi-account Anthropic auth plugin for OpenCode with quota-aware load balancing

Readme

anthropic-multi-auth

Multi-account Anthropic auth plugin for OpenCode with quota-aware load balancing.

Features

  • Multi-account support: Add multiple Anthropic accounts (Claude Pro/Max)
  • Quota-aware load balancing: Automatically selects the account with the lowest quota utilization at session start
  • Sticky sessions: Stays on the same account throughout a session for consistency
  • Automatic failover: On 429 rate limit errors, automatically switches to the next available account
  • Token refresh: Automatically refreshes OAuth tokens when expired
  • Account management: List and remove accounts via interactive CLI
  • Usage inspection: View per-account Anthropic quota utilization from the login menu
  • First-time migration: Automatically imports accounts from OpenAuth if available

Installation

Add the plugin to your OpenCode configuration in opencode.json:

{
  "plugins": ["anthropic-multi-auth"]
}

Setup

Adding Accounts

Run the OpenCode auth flow to add accounts:

opencode auth login

When prompted, select "Claude Pro/Max" to authorize a new account. After successful authorization, you'll be asked if you want to add another account. Repeat this process to add multiple Anthropic accounts.

Managing Accounts

To view and manage your configured accounts:

opencode auth login

Select "Manage Accounts" to see your accounts and remove ones you no longer need.

Viewing Account Usage

To view current utilization for all configured accounts:

opencode auth login

Select "View Account Usage" to print each account's status and usage utilization.

How It Works

Account Selection

When a session starts, the plugin:

  1. Loads your saved accounts from ~/.config/opencode/anthropic-accounts.json
  2. Checks the quota usage API for each account
  3. Selects the account with the lowest utilization
  4. Marks it as the active account for the session

Session Stickiness

Once an account is selected at session start, it remains active throughout the session. This ensures consistent behavior within a single session.

Rate Limit Handling

If an API request returns a 429 (Too Many Requests) response:

  1. The plugin waits the specified retry period
  2. Automatically switches to the next available account
  3. Retries the request with the new account
  4. If all accounts are rate-limited, returns an error with the shortest wait time

Token Refresh

When tokens expire (checked via the expires timestamp):

  1. The plugin automatically refreshes the OAuth token
  2. Saves the new credentials to storage
  3. Syncs with OpenAuth to maintain consistency

Account Storage

Accounts are stored at:

~/.config/opencode/anthropic-accounts.json

Each account includes:

  • access: OAuth access token
  • refresh: OAuth refresh token
  • expires: Token expiration timestamp (milliseconds)
  • addedAt: When the account was added
  • enabled: Whether this account is active
  • email: (optional) User email from OAuth
  • label: (optional) Friendly name for the account

Comparison with Builtin Auth

This plugin extends the OpenCode builtin opencode-anthropic-auth with:

  • Multi-account support (builtin only supports one account)
  • Quota-aware account selection (builtin doesn't consider quota)
  • Automatic failover on rate limits (builtin doesn't switch accounts)

If no accounts are configured, the plugin falls back to the builtin auth plugin, so the plugin is fully backward compatible.

Troubleshooting

No accounts configured

Symptom: Plugin doesn't seem to be working.

Solution: Run opencode auth login and select "Claude Pro/Max" to add at least one account.

All accounts rate-limited

Symptom: Error: "All accounts rate-limited. Shortest wait: Xs."

Solution: Wait the specified time before trying again. If this happens frequently, consider adding more accounts.

Token refresh failures

Symptom: Error during session with 401/403 status codes.

Solution:

  1. Verify your refresh tokens haven't been revoked
  2. Run opencode auth login → "Manage Accounts" to remove and re-add affected accounts
  3. Make sure your internet connection is stable

Plugin not loading

Symptom: Plugin doesn't appear to be active.

Solution:

  1. Check opencode.json has the correct plugin name: "anthropic-multi-auth"
  2. Run bun install (or npm install) to ensure dependencies are installed
  3. Check OpenCode version is compatible (requires @opencode-ai/plugin@^0.4.45)

License

MIT