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

v1.0.0

Published

OpenAI OAuth multi-account plugin for Opencode - login to multiple OpenAI accounts and auto-rotate on rate limits

Downloads

100

Readme

OpenAI Multi-Account OAuth Plugin for OpenCode

npm version License: MIT CI

Enable OpenCode to authenticate against OpenAI via OAuth with multi-account support. Automatically rotates between accounts when rate-limited to maximize your usage.

What You Get

  • OpenAI OAuth Authentication — Use your OpenAI ChatGPT account credentials
  • Multi-account support — Add multiple OpenAI accounts, auto-rotates when rate-limited
  • Smart account selection — Multiple strategies: sticky, round-robin, or hybrid
  • Rate limit handling — Automatic backoff and recovery
  • Health-based routing — Prioritize accounts with better performance history
  • GPT-5.x Support — Works with GPT-5.2, GPT-5.2 Codex, GPT-5.1 Codex Max and more

[!CAUTION] Using this plugin may violate OpenAI's Terms of Service. By using this plugin, you acknowledge:

  • This is an unofficial tool not endorsed by OpenAI
  • Your account may be suspended or rate-limited
  • You assume all risks associated with using this plugin

Recommendation: Use responsibly and respect OpenAI's usage policies.


Installation

Option A: Let an LLM do it

Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):

Install the opencode-multi-openai-auth plugin and configure OpenAI models by following: https://raw.githubusercontent.com/MoYeRanqianzhi/opencode-multi-openai-auth/main/README.md

Option B: Manual setup

  1. Add the plugin to ~/.config/opencode/opencode.json:

    {
      "plugin": ["opencode-multi-openai-auth@latest"]
    }
  2. Add OpenAI provider and models — copy the full configuration below

  3. Login with your OpenAI account:

    opencode auth login

    Select "OpenAI OAuth (Multi-Account)" when prompted.

  4. Use it:

    opencode run "Hello" --model=openai/gpt-5.2

Step-by-Step Instructions

  1. Edit the OpenCode configuration file at ~/.config/opencode/opencode.json

    Note: This path works on all platforms. On Windows, ~ resolves to your user home directory (e.g., C:\Users\YourName).

  2. Add the plugin to the plugin array

  3. Add the model definitions from the Full models configuration section

  4. Set provider to "openai" and choose a model

Verification

opencode run "Hello" --model=openai/gpt-5.2 --variant=medium

Models

Model Reference

| Model | Variants | Notes | |-------|----------|-------| | gpt-5.2 | none, low, medium, high, xhigh | GPT-5.2 with reasoning | | gpt-5.2-codex | low, medium, high, xhigh | GPT-5.2 Codex optimized for coding | | gpt-5.1-codex-max | low, medium, high, xhigh | GPT-5.1 Codex Max for complex tasks |

Using variants:

opencode run "Hello" --model=openai/gpt-5.2-codex --variant=xhigh

Add this to your ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-multi-openai-auth@latest"],
  "provider": {
    "openai": {
      "name": "OpenAI",
      "options": {
        "reasoningEffort": "medium",
        "reasoningSummary": "auto",
        "textVerbosity": "medium",
        "include": ["reasoning.encrypted_content"],
        "store": false
      },
      "models": {
        "gpt-5.2": {
          "name": "GPT 5.2 (OAuth)",
          "limit": { "context": 272000, "output": 128000 },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "variants": {
            "none": {
              "reasoningEffort": "none",
              "reasoningSummary": "auto",
              "textVerbosity": "medium"
            },
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto",
              "textVerbosity": "medium"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto",
              "textVerbosity": "medium"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            }
          }
        },
        "gpt-5.2-codex": {
          "name": "GPT 5.2 Codex (OAuth)",
          "limit": { "context": 272000, "output": 128000 },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "variants": {
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto",
              "textVerbosity": "medium"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto",
              "textVerbosity": "medium"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            }
          }
        },
        "gpt-5.1-codex-max": {
          "name": "GPT 5.1 Codex Max (OAuth)",
          "limit": { "context": 272000, "output": 128000 },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "variants": {
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "detailed",
              "textVerbosity": "medium"
            }
          }
        }
      }
    }
  }
}

Multi-Account Setup

Add multiple OpenAI accounts for higher combined quotas. The plugin automatically rotates between accounts when one is rate-limited.

opencode auth login  # Run again to add more accounts

How It Works

  1. Each account's rate limit status is tracked independently
  2. When one account hits a rate limit, the plugin automatically switches to the next available account
  3. Accounts recover after their rate limit window expires
  4. Health scores track account reliability for optimal routing

Account Selection Strategies

| Strategy | Description | Best For | |----------|-------------|----------| | sticky | Stay on current account until rate-limited | Single account usage | | round-robin | Rotate through accounts on each request | Even distribution | | hybrid | Health + token bucket based selection | Multiple accounts (default) |


Configuration

Create ~/.config/opencode/openai-multi-auth.json for optional settings:

{
  "account_selection_strategy": "hybrid",
  "switch_on_first_rate_limit": true,
  "max_rate_limit_wait_seconds": 300,
  "quiet_mode": false,
  "pid_offset_enabled": false
}

Configuration Options

| Option | Default | Description | |--------|---------|-------------| | account_selection_strategy | "hybrid" | How to select accounts: sticky, round-robin, hybrid | | switch_on_first_rate_limit | true | Switch to next account immediately on rate limit | | max_rate_limit_wait_seconds | 300 | Maximum seconds to wait for rate limit recovery | | quiet_mode | false | Hide toast notifications about account switching | | pid_offset_enabled | false | Offset account selection by process ID (for parallel agents) |

Health Score Configuration

Fine-tune the health-based account selection:

{
  "health_score": {
    "initial": 70,
    "success_reward": 1,
    "rate_limit_penalty": -10,
    "failure_penalty": -20,
    "recovery_rate_per_hour": 2,
    "min_usable": 50,
    "max_score": 100
  }
}

Token Bucket Configuration

Control request rate limiting per account:

{
  "token_bucket": {
    "max_tokens": 50,
    "regeneration_rate_per_minute": 6,
    "initial_tokens": 50
  }
}

Configuration Paths

| File | Path | |------|------| | Main config | ~/.config/opencode/opencode.json | | Accounts | ~/.config/opencode/openai-accounts.json | | Plugin config | ~/.config/opencode/openai-multi-auth.json |

Windows users: ~ resolves to your user home directory (e.g., C:\Users\YourName). On Windows, the config directory is %APPDATA%\opencode\.


Troubleshooting

Quick Reset: Most issues can be resolved by deleting ~/.config/opencode/openai-accounts.json and running opencode auth login again.

Multi-Account Auth Issues

If you encounter authentication issues with multiple accounts:

  1. Delete the accounts file:
    rm ~/.config/opencode/openai-accounts.json
  2. Re-authenticate:
    opencode auth login

"All Accounts Rate-Limited"

  1. Wait for rate limit window to expire (usually 60 seconds)
  2. Add more accounts to increase throughput
  3. Check if max_rate_limit_wait_seconds is set too low

OAuth Callback Issues

macOS / Linux:

lsof -i :51120
kill -9 <PID>
opencode auth login

Windows (PowerShell):

netstat -ano | findstr :51120
taskkill /PID <PID> /F
opencode auth login

If the browser doesn't open automatically:

  1. Copy the OAuth URL from the terminal
  2. Paste it into your browser manually
  3. Complete the login process

Using with oh-my-opencode

When using with oh-my-opencode, you can configure agents to use OpenAI models:

// ~/.config/opencode/oh-my-opencode.json
{
  "agents": {
    "oracle": { "model": "openai/gpt-5.2" },
    "explore": { "model": "openai/gpt-5.2-codex" }
  }
}

Tip: When spawning parallel subagents, enable pid_offset_enabled: true in plugin config to distribute sessions across accounts.


Environment Variables

OPENCODE_OPENAI_DEBUG=1 opencode   # Enable debug logging
OPENCODE_OPENAI_DEBUG=2 opencode   # Verbose logging

GitHub Actions Auto-Publish

This project uses GitHub Actions for automatic npm publishing:

  • CI Workflow (ci.yml): Runs on every push and PR, tests on Node.js 18/20/22
  • Publish Workflow (npm-publish.yml): Publishes to npm on version tags or manual trigger

Setup for Your Fork

  1. Get an NPM access token from npmjs.com
  2. Add it as a GitHub secret named NPM_TOKEN
  3. Push a version tag to trigger publish: git tag v1.0.0 && git push --tags

Development

git clone https://github.com/MoYeRanqianzhi/opencode-multi-openai-auth.git
cd opencode-multi-openai-auth

npm install      # Install dependencies
npm run build    # Build TypeScript
npm test         # Run tests (46 tests)
npm run typecheck # Type check

API Reference

Exported Functions

import { createOpenAIMultiAuthPlugin, AccountManager } from 'opencode-multi-openai-auth';

// Create the plugin
const plugin = createOpenAIMultiAuthPlugin();

// Or with custom provider ID
const plugin = createOpenAIMultiAuthPlugin('custom-openai');

AccountManager

The AccountManager class handles multi-account state:

const manager = await AccountManager.loadFromDisk(authDetails);
const count = manager.getAccountCount();
const current = manager.getCurrentAccount();

Credits


License

MIT License. See LICENSE for details.

Intended Use

  • Personal / internal development only
  • Respect OpenAI's quotas and usage policies
  • Not for production services or bypassing intended limits

Warning

By using this plugin, you acknowledge:

  • Terms of Service risk — This approach may violate ToS of OpenAI
  • Account risk — OpenAI may suspend or rate-limit accounts
  • No guarantees — APIs may change without notice
  • Assumption of risk — You assume all legal, financial, and technical risks

Disclaimer

  • Not affiliated with OpenAI. This is an independent open-source project.
  • "OpenAI", "ChatGPT", and "GPT" are trademarks of OpenAI, Inc.