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-9router-model-sync

v0.1.1

Published

OpenCode plugin that syncs a self-hosted 9router /v1/models catalog into your provider config

Readme

opencode-9router-model-sync

OpenCode plugin that fills provider.9router.models from a self-hosted 9router OpenAI-compatible /v1/models endpoint.

Without it, an empty models: {} stays empty and the model picker has nothing to show. With it, the catalog is loaded at startup (and can be refreshed with /9router-sync).

Quick start

  1. Install the plugin and define a provider with your self-hosted base URL:
// opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-9router-model-sync"],
  "provider": {
    "9router": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "9Router",
      "options": {
        "baseURL": "https://your-9router-host/v1"
      },
      "models": {}
    }
  }
}

options.baseURL is required — OpenCode needs it for chat, and this plugin reads the same value for /models.

  1. Provide an API key (one of):

    • /connect in OpenCode and add credentials for 9router
    • env: 9ROUTER_API_KEY
    • or provider.9router.options.apiKey in config
  2. Restart OpenCode.

  3. Pick a model as 9router/<model-id>, or force a refresh with /9router-sync.

Auth

API key resolution order:

  1. provider.9router.options.apiKey
  2. 9ROUTER_API_KEY
  3. OpenCode auth store (auth.json entry for 9router, type api)

If the key is missing, the last disk cache is used when present; otherwise sync fails with a clear error.

Plugin options

{
  "plugin": [
    [
      "opencode-9router-model-sync",
      {
        "providerId": "9router",
        "timeoutMs": 15000
      }
    ]
  ]
}

| Option | Default | Description | | --- | --- | --- | | providerId | "9router" | Key under config.provider | | syncCommands | ["9router-sync"] | Slash commands that force a revalidate | | timeoutMs | 10000 | Fetch timeout (ms) | | apiKeyEnv | ["9ROUTER_API_KEY"] | Env vars checked for an API key | | cachePath | $XDG_CACHE_HOME/opencode/<providerId>-models.json | Disk cache path | | authPath | $XDG_DATA_HOME/opencode/auth.json | OpenCode auth file |

Refresh

/9router-sync force-fetches /models (skips ETag short-circuit) and refreshes the in-memory catalog without quitting OpenCode.

Caching

Catalog responses are written under the XDG cache dir. Conditional requests use ETag / Last-Modified when available (304 reuses the cache).

Local development

npm install
npm test
npm run build

Point OpenCode at the built entry:

{
  "plugin": ["file:///absolute/path/to/opencode-9router-model-sync/dist/index.js"]
}

Requires Node.js 20+. Restart OpenCode after config or build changes.

License

MIT