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

pi-multi-auth

v0.10.0

Published

Pi extension for multi-provider credential management, OAuth login, and account rotation.

Downloads

808

Readme

pi-multi-auth

npm version License

pi-multi-auth is a Pi extension for multi-provider credential management, OAuth login, and quota-aware account rotation.

  • npm: https://www.npmjs.com/package/pi-multi-auth
  • GitHub: https://github.com/MasuRii/pi-multi-auth

Capabilities

  • Wraps discovered Pi providers with multi-account rotation, quota-aware cooldowns, failover, health scoring, and optional pool selection.
  • Supports OAuth credential management for providers exposed by Pi and registers first-class Cline, Kilo, Kimi For Coding, and Qwen OAuth login and refresh handling.
  • Applies per-credential request overrides for provider base URLs and headers, with Cloudflare Workers AI credentials using account-scoped OpenAI-compatible base URLs and token/account discovery during credential setup.
  • Enriches status-only provider failures with bounded diagnostic probes so authentication, permission, billing, and rate-limit errors include actionable provider response details when available.
  • Provides lightweight rotation for API-key providers that do not expose external usage state, including delegated parent-session lease reuse.
  • Filters removed legacy Google Gemini CLI and Google Antigravity providers so stale provider definitions are not offered for credential setup or usage refreshes.
  • Persists extension state and usage snapshots under Pi's runtime directory while keeping local config.json and debug output outside the published package.
  • Coordinates fresh usage refreshes across selection, startup, modal, and manual refresh flows with bounded concurrency, candidate windows, cooldowns, and circuit breaking.

Provider capability matrix

The following table shows credential and usage support for each recognized provider. Providers marked API Key appear in the credential setup dialog; providers marked OAuth support browser-based or device-code login flows.

| Provider | API Key | OAuth | Usage / Quota | Notes | |---|---|---|---|---| | Anthropic | ✅ | — | ✅ | Usage via dedicated Anthropic endpoint | | Amazon Bedrock | ✅ | — | — | | | Azure OpenAI Responses | ✅ | — | — | | | BlazeAPI | ✅ | — | ✅ | Usage via /api/usage (daily requests + premium credits); rotation defaults to usage-based and routes credentials by plan tier (Premium → Pro → Free) with automatic fallback when the active tier's daily-request or premium-credit budget is exhausted | | Cerebras | ✅ | — | — | | | Cline | — | ✅ | — | OAuth only; browser callback | | Cloudflare Workers AI | ✅ | — | — | Requires account-scoped base URL | | Cloudflare AI Gateway | ✅ | — | — | | | DeepSeek | ✅ | — | — | | | Fireworks | ✅ | — | — | | | GitHub Copilot | ✅ | — | ✅ | Legacy discovery; usage via Copilot API | | Google Gemini | ✅ | — | — | | | Google Vertex AI | ✅ | — | — | | | Groq | ✅ | — | — | | | Hugging Face | ✅ | — | — | | | Kimi For Coding | ✅ | ✅ | ✅ | Device-code OAuth; usage via /usages endpoint | | Kilo | — | ✅ | — | OAuth only; device authorization | | MiniMax | ✅ | — | — | | | MiniMax (China) | ✅ | — | — | | | Mistral | ✅ | — | — | | | OpenAI | ✅ | — | ✅ | Usage via Codex entitlement | | OpenAI Codex | ✅ | — | ✅ | Legacy discovery; Codex usage + entitlement | | OpenCode Go | ✅ | — | — | | | OpenCode Zen | ✅ | — | — | | | OpenRouter | ✅ | — | — | | | Qwen | — | ✅ | — | OAuth only; device code with PKCE | | Vercel AI Gateway | ✅ | — | — | | | xAI | ✅ | — | — | | | Xiaomi MiMo | ✅ | — | — | | | ZAI | ✅ | — | — | |

Legacy providers openai-codex and github-copilot are retained for discovery and migration seed paths. Removed providers Google Gemini CLI and Google Antigravity are filtered from credential setup and usage refreshes.

Repository structure

This package follows a conventional src/ layout. The published entrypoint stays at the repository root as index.ts, runtime implementation lives under src/, and package exports map stable balancer subpaths to src/balancer/*.

pi-multi-auth/
├── index.ts
├── src/
│   ├── index.ts
│   ├── balancer/
│   ├── formatters/
│   ├── usage/
│   └── *.ts
├── tests/
├── .env.example
├── package.json
├── package-lock.json
├── tsconfig.json
├── tsconfig.test.json
├── README.md
├── CHANGELOG.md
└── LICENSE

Installation

npm package

pi install npm:pi-multi-auth

Local extension folder

Place this folder in one of Pi's extension discovery paths:

| Scope | Path | |-------|------| | Global default | ~/.pi/agent/extensions/pi-multi-auth (respects PI_CODING_AGENT_DIR) | | Project | .pi/extensions/pi-multi-auth |

Pi discovers the extension through the root index.ts entry listed in package.json, which forwards to src/index.ts.

The global path above is the default when PI_CODING_AGENT_DIR is unset; otherwise Pi resolves the global extension path under $PI_CODING_AGENT_DIR/extensions/pi-multi-auth.

Configuration

Runtime configuration lives in config.json at the extension root. The extension creates the file automatically with defaults on first load if it does not already exist.

| Key | Type | Default | Purpose | |-----|------|---------|---------| | debug | boolean | false | Enables JSONL debug logging under debug/pi-multi-auth-debug.jsonl | | hiddenProviders | string[] | [] | Hides selected providers from the multi-auth UI and runtime work | | rotationModes | Record<string, "round-robin" \| "usage-based" \| "balancer"> | {} | Overrides provider rotation modes outside multi-auth.json |

The published package intentionally excludes config.json and debug/; both are created locally as needed by the running extension. Usage snapshots are cached in Pi's runtime directory as multi-auth-usage-cache.json so operational and display-only usage state can survive extension restarts without publishing local state.

Credential request overrides

Credentials may include a request object with provider-specific request settings:

| Key | Type | Purpose | |-----|------|---------| | request.baseUrl | string | Overrides the model base URL for that credential after URL validation | | request.headers | Record<string, string> | Adds credential-scoped headers to the provider request |

Cloudflare Workers AI credentials must use https://api.cloudflare.com/client/v4/accounts/<account_id>/ai/v1 as the OpenAI-compatible base URL. When adding a Cloudflare API-key credential, the extension can extract cfat_ tokens, account IDs, dashboard token URLs, or full Workers AI base URLs from pasted input. It discovers the base URL automatically when the token can list exactly one account; otherwise add request.baseUrl manually for the intended account.

Environment variables

The extension reads optional environment variables to override OAuth client settings, runtime paths, and display behavior. See .env.example for a copy-ready template.

OAuth client overrides

| Variable | Provider | Default | Purpose | |---|---|---|---| | KIMI_CODING_OAUTH_CLIENT_ID | Kimi For Coding | Built-in app ID | Override the OAuth application client ID | | QWEN_OAUTH_CLIENT_ID | Qwen | Built-in app ID | Override the OAuth application client ID |

Runtime path overrides

| Variable | Default | Purpose | |---|---|---| | PI_DELEGATED_AUTH_RUNTIME_DIR | Pi agent runtime directory | Override the directory for usage cache and multi-auth.json | | PI_MULTI_AUTH_RUNTIME_DIR | Pi agent runtime directory | Legacy alias for PI_DELEGATED_AUTH_RUNTIME_DIR; used only when the delegated variable is unset | | PI_CODING_AGENT_DIR | ~/.pi/agent | Override the Pi agent directory (affects models.json and runtime path resolution) |

Display overrides

| Variable | Default | Purpose | |---|---|---| | PI_MULTI_AUTH_ASCII_BORDERS | Auto-detected | Force ASCII border rendering in the extension TUI (1, true, yes, on) |

Validation

npm run build
npm run lint
npm run test
npm run check

Related Pi Extensions

License

MIT