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

magpie-oc2api

v0.2.1

Published

OpenCode / magpie provider plugin: signs in to Vercel and spreads oc2api requests over every oc2api project on that account

Readme

magpie-oc2api

在 magpie 里使用你在 Vercel 上的 oc2api 实例。

只做授权,不改你的项目。 登录一次 Vercel,插件扫出该账号下所有名字含 oc2api 的项目,把它们当作一组「号」内部轮询。不部署、不写环境变量、不改任何配置。

为什么这样最省事

oc2api 的免费额度按出口 IP 计量。你每个 Vercel 项目的出口 IP 都不同,于是 一个 Vercel 账号下的多个 oc2api-* 项目就等于多个独立额度池。这个插件把它们合起来用:

一个 magpie 账号(你的 Vercel 邮箱)
├── oc2api-us    ┐
├── oc2api-eu    │
├── oc2api-asia  ├─ 每个项目一个独立出口,自动轮询,429 自动切下一个
├── oc2api-eta   │
└── oc2api-au    ┘

装

magpie plugin add github:zhuweiyou/magpie-oc2api

然后在供应商那一行点 Sign in with Vercel。magpie 会打开 Vercel 自己的设备码页面, 浏览器里确认一次即可。再加一个 Vercel 账号就再登录一次,两组互不干扰。

密钥怎么来的

不需要你填,也不会覆盖你的:

| 项目情况 | 做法 | | --- | --- | | 有 API_KEY(你手设的也行) | 通过 Vercel 的 env pull 读出明文直接用 | | 完全没有 API_KEY | 不带密钥访问(适用于不校验密钥的部署) |

这一点和「读不回密钥」的常见印象不同:项目环境变量列表确实只给密文, 但 vercel env pull 那个接口给的是明文,插件用的就是它。所以你手设的那把密钥原样保留, 线上跑的和插件用的是同一个密钥。

模型

模型列表只从一个项目读,其余项目默认为一致(它们跑的是同一份 oc2api)。 读不到时用内置的那几个,不会让供应商变空。

模型名不带项目前缀,因为项目是内部轮询的,你选的是「模型」不是「某台机器」:

big-pickle
beam-free
deepseek-v4.1-flash-free
glm-5.3-flash-free
mimo-v2.6-flash-free
...

代理只放行 big-pickle 与所有 *-free,插件也照这个过滤。

轮询与故障切换

每次请求挑一个座位发出去:

  • 负载分散:优先选当时并发最低、累计发送最少的,所以流量平摊到所有出口, 不会全压在第一个上;
  • 429 / 403 / 401 自动切换:oc2api 的限流是按出口算的,一个出口用完就换下一个, 最多试 6 个;
  • 失败按响应头休息:oc2api 的 429 会带 Retry-After,座位就按它说的时长休息 (最长一天);没说明的才退回 10 分钟,其余座位继续跑,到点自动恢复;
  • 切换不影响流式:oc2api 的 429/403 在响应头阶段就返回,还没开始吐内容, 所以换座位不会把回答切断。

被拒的项目会从健康列表里暂时移除,账号卡片会写出来,不会静默失败。

账号卡片与工具

供应商卡片显示 5 seats,每个座位一行:名字、密钥是否存在、已发送多少、 是否正在休息。

两个工具(magpie 挂在 /mcp/magpie/tools,任何 agent 都能调):

| 工具 | 作用 | | --- | --- | | oc2api_seats | 列出座位:域名、有无密钥、出口 IP、已发送次数、健康状态 | | oc2api_models | 从某一个座位读模型列表 |

账号行上的 Check in now 会强制重扫一次(新建或删除了项目后点它,不必等一分钟)。

插件页

侧边栏「插件」里有一页 oc2api on Vercel,写清楚它怎么用,并列出这个插件自己的 供应商行(oc2api,多登录一个 Vercel 账号就多一行 oc2api#邮箱)。

它不列出 Codex、WorkBuddy 之类的其他渠道:providers:list 返回的是整个 magpie 的供应商, 而这一页是 oc2api 插件自己的说明页,把别人的账号摆在这里既没用,也容易让人以为它在扫别的东西。 所以只按 oc2api / oc2api# 过滤。

magpie 的页面沙箱不给它自己的网络,只给它 package.json 里声明过的读:

"magpie": {
  "page": { ... },
  "permissions": ["providers:list"]
}

没声明的读会被 magpie 当场拒掉,页面上显示 oc2api on Vercel 没有声明读取 providers:list。 座位清单不在这一页,在供应商的账号卡片和 oc2api_seats 工具里。

数据放在哪

<magpie 配置目录>/oc2api-vercel/accounts/<邮箱>.json

只记录座位清单(名字、域名、有没有密钥)。密钥本身不落盘——每次需要时从 Vercel 现读,缓存半小时。登录凭据照常由 magpie 存在 plugin-auth.json。

边界

  • 只读:这个插件没有部署、创建、删除的能力。项目要新建或改代码,用你的 git 流程。
  • 项目名:匹配规则是「名字里含 oc2api」(不区分大小写),oc2api-us、 my-oc2api-x 都算,app 不算。
  • 域名:用项目的 production 别名(<项目>.vercel.app),它在多次部署之间不变。
  • 无出口保证:轮询不等于保证每个出口都还有额度,用完的座位按 Retry-After 休息, 到点后会再试。

开发

npm test

31 项测试:项目匹配、座位轮询分散、失败退出与恢复、密钥读取、模型过滤与命名、 配置目录读写(含路径穿越防护)、页面声明的读与它实际读的一致、插件页只画自己的行。

真实账号验证过:扫出 5 个座位、5 个不同出口 IP、9 个模型、连续 10 次请求 严格轮流落在 5 个座位上且全部 200。