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.5.10

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 5 hours (configurable)
  • Concurrency Safe - Handles multiple concurrent requests without state corruption

Installation

npm install -g opencode-ollama-multi-auth

Configuration

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

{
  "model": "ollama-multi/kimi-k2.5",
  "provider": {
    "ollama-multi": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://ollama.com/v1"
      },
      "models": {
        "kimi-k2.5": { "id": "kimi-k2.5", "name": "Kimi K2.5", "family": "kimi" },
        "gemma4:31b-cloud": { "id": "gemma4:31b-cloud", "name": "Gemma 4 31B", "family": "gemma" }
      }
    }
  },
  "plugin": [
    ["opencode-ollama-multi-auth", {
      "ollamaMultiAuth": {
        "keys": [
          "your-ollama-api-key-1",
          "your-ollama-api-key-2",
          "your-ollama-api-key-3"
        ],
        "failWindowMs": 18000000,
        "maxRetries": 5
      }
    }]
  ]
}

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) | | maxRetries | number | 5 | Maximum key rotations per request | | 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

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

Pre-configured Ollama Cloud models:

  • ollama-multi/kimi-k2.5 - Moonshot Kimi K2.5
  • ollama-multi/qwen3.5:397b - Alibaba Qwen 3.5 397B
  • ollama-multi/gemma4:31b-cloud - Google Gemma 4 31B

License

MIT License