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

v1.6.3

Published

Opencode plugin for Ollama Cloud with multiple API keys and automatic failover

Readme

opencode-ollama-multi-auth

npm version License: MIT

OpenCode plugin for Ollama Cloud with multiple API keys and automatic failover. Never run out of API quota!

Features

  • Multiple API Keys - Add unlimited API keys from different Ollama Cloud accounts
  • Automatic Failover - Automatically rotates to next key when current one fails (401, 403, 429)
  • Auto Recovery - Re-enables failed keys after configurable fail window (default: 5 hours)
  • Dynamic Model Discovery - Automatically discovers all available Ollama Cloud models (no manual model config needed)
  • TUI Notifications - Toast notifications for key rotations, recovery, and exhaustion
  • Key Management Tools - Built-in tools to list, switch, and reset API keys on the fly

Installation

npm install -g opencode-ollama-multi-auth

Configuration

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

{
  "model": "ollama-multi/kimi-k3",
  "provider": {
    "ollama-multi": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://ollama.com/v1"
      }
    }
  },
  "plugin": [
    ["opencode-ollama-multi-auth", {
      "ollamaMultiAuth": {
        "keys": [
          "your-ollama-api-key-1",
          "your-ollama-api-key-2",
          "your-ollama-api-key-3"
        ]
      }
    }]
  ]
}

Models are auto-discovered from Ollama Cloud — no need to list them manually.

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | keys | string[] | [] | Array of API keys to rotate through | | failWindowMs | number | 18000000 | Time in ms before retrying a failed key (default: 5 hours) | | notifications | boolean | true | Show TUI toast notifications on key rotation, recovery, and errors | | autoDiscoverModels | boolean | true | Automatically discover all available Ollama Cloud models (set to false to configure models manually) | | providerId | string | "ollama-multi" | Provider ID to manage (for custom providers) |

Environment Variables

You can also set keys via environment variables:

export OLLAMA_API_KEY="your-first-key"
export OLLAMA_API_KEY_1="your-second-key"
export OLLAMA_API_KEY_2="your-third-key"

Keys from environment variables are merged with config keys.

How It Works

Request 1: Using Key #1 ✅ Success
Request 2: Using Key #1 ❌ Rate limited (429)
           ↓ Automatic rotation
Request 2: Using Key #2 ✅ Success
...

The plugin intercepts API requests and:

  1. Uses the first available key from your list
  2. Detects auth errors (401, 403, 429)
  3. Marks failed key and rotates to next available key
  4. Re-enables failed keys after the fail window expires

State Files

The plugin manages these files automatically:

  • ~/.local/share/opencode/auth.json - Current active key
  • ~/.opencode/ollama-keys-state.json - Key failure history with timestamps

Key Management Tools

The plugin registers tools you can invoke during a session:

| Tool | Description | Parameters | |------|-------------|------------| | list_ollama_keys | List all keys with status (active, healthy, failed with recovery time) | none | | switch_ollama_key | Manually switch to a specific key by index | index (1-based key index) | | reset_ollama_keys | Clear failed status — optionally for a specific key | index (optional, resets all if omitted) |

Testing

The plugin includes a mock server for testing key rotation:

cd node_modules/opencode-ollama-multi-auth
node scripts/mock-server.js

Then configure a test provider in opencode.json pointing to http://127.0.0.1:11435/v1 with test keys.

Available Models

All Ollama Cloud models are auto-discovered by default (cached for 15 minutes). Run /models in the TUI to see the full list.

To manually configure models instead, set autoDiscoverModels: false and add them to your provider config:

"models": {
  "kimi-k3": { "id": "kimi-k3", "name": "Kimi K3" },
  "gemma4:31b": { "id": "gemma4:31b", "name": "Gemma 4 31B" }
}

License

MIT License