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-plugin

v0.1.5

Published

Dynamic 9router provider plugin for opencode

Readme

Opencode 9Router Plugin

Preview plugin

Dynamic 9router provider plugin for opencode.

It discovers available models from your 9router endpoint at startup and injects them into opencode automatically, so model lists do not need to be hardcoded in opencode.json.

Features

  • Discovers models dynamically from OPENCODE_9ROUTER_URL (default: http://localhost:20128/v1)
  • Registers provider 9router using @ai-sdk/openai-compatible
  • Sends OPENCODE_9ROUTER_API_KEY as Bearer auth when discovering models
  • Injects dynamically discovered models into opencode config at runtime
  • Does not write opencode config from the runtime plugin
  • Includes an explicit installer/check CLI for safer setup and troubleshooting

Recommended Install

Use opencode's native plugin installer:

opencode plugin opencode-9router-plugin

Then set your API key and restart opencode.

Windows (cmd):

setx OPENCODE_9ROUTER_API_KEY "sk-..."

macOS/Linux:

export OPENCODE_9ROUTER_API_KEY="sk-..."

If your 9router endpoint is not the default local URL, also set:

export OPENCODE_9ROUTER_URL="http://localhost:20128/v1"

Windows (cmd):

setx OPENCODE_9ROUTER_URL "http://localhost:20128/v1"

Restart opencode, then verify:

opencode models 9router

Fallback Installer

If the native installer is unavailable, use the package CLI:

npx opencode-9router-plugin install

The CLI first tries opencode plugin opencode-9router-plugin. If that fails, it falls back to safe config editing.

Useful options:

npx opencode-9router-plugin install --global
npx opencode-9router-plugin install --project
npx opencode-9router-plugin install --config ./opencode.json
npx opencode-9router-plugin install --dry-run
npx opencode-9router-plugin install --yes
npx opencode-9router-plugin install --manual

The fallback editor:

  • detects OPENCODE_CONFIG and warns about OPENCODE_CONFIG_CONTENT
  • supports global and project config targets
  • creates backups before writing existing files
  • writes atomically through a temp file and rename
  • avoids duplicate plugin entries, including tuple entries like ["opencode-9router-plugin", {}]
  • refuses to edit JSONC files with comments because preserving comments safely is not guaranteed

Check Setup

Run diagnostics:

npx opencode-9router-plugin check

It checks:

  • target config path
  • whether config parses successfully
  • whether plugin entry is present
  • whether OPENCODE_9ROUTER_API_KEY is set
  • whether opencode models 9router returns models

Uninstall

Use opencode's native plugin management if available. Otherwise:

npx opencode-9router-plugin uninstall --global

or:

npx opencode-9router-plugin uninstall --project

Manual Config

If you prefer to edit config manually, add the package name to plugin:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-9router-plugin"]
}

Do not hardcode model lists. The plugin discovers them dynamically at startup.

Environment Variables

  • OPENCODE_9ROUTER_URL (optional): 9router base URL. Default http://localhost:20128/v1
  • OPENCODE_9ROUTER_API_KEY (recommended): API key used by provider options and model discovery requests
  • OPENCODE_9ROUTER_TIMEOUT_MS (optional): fetch timeout in ms. Default 5000
  1. Create a tag such as v0.1.0.
  2. Publish to npm manually or with GitHub Actions on tagged releases.

Troubleshooting

  • Restart opencode after changing config or installing plugins.
  • If /model does not show 9router models, run npx opencode-9router-plugin check.
  • If models are empty, verify that your 9router endpoint is running and /models is reachable.
  • If you see Missing API Key, set OPENCODE_9ROUTER_API_KEY and restart opencode.
  • If you previously used a local development copy, remove duplicate local entries such as ./plugins/opencode-9router.ts before switching to the npm package.

Github Repository

https://github.com/mdhb2/opencode-9router-plugin