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

v1.3.0

Published

OpenCode plugin to use models from agentrouter.org

Readme

opencode-agentrouter

OpenCode plugin for using AgentRouter models inside OpenCode.

How it works

The plugin patches globalThis.fetch at module load time. For any request to agentrouter.org it:

  1. Injects identity headers — AgentRouter only allows requests from whitelisted coding-agent clients. The plugin adds the required headers so OpenCode is accepted.
  2. Sanitizes Claude request bodies — Strips reasoning_effort, reasoning, and cache_control fields that AgentRouter rejects.
  3. Injects adaptive thinking — Automatically sets thinking: { type: "adaptive" } for Claude models. Opus 4.7 requires adaptive thinking; older Claude models are upgraded from type: "enabled" (deprecated) to type: "adaptive".
  4. Auto-retries on sensitive content errors — When AgentRouter returns sensitive_words_detected, the plugin retries with exponential backoff (up to 30 attempts).
  5. Serializes Claude requests — Queues Claude model calls with cooldown to avoid rate limiting.

Requests to all other domains pass through untouched.

Install

Option A: npm plugin (recommended)

{
  "plugin": ["opencode-agentrouter"]
}

Add to your OpenCode config (~/.config/opencode/opencode.json). OpenCode installs npm plugins automatically.

Option B: local plugin

Copy dist/index.js to:

~/.config/opencode/plugins/agentrouter-auth.js

Files in the plugins directory are auto-loaded.

Configure provider

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-agentrouter"],
  "provider": {
    "agentrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "AgentRouter",
      "options": {
        "baseURL": "https://agentrouter.org/v1",
        "apiKey": "sk-YOUR-KEY-HERE"
      },
      "models": {
        "claude-opus-4-6": {
          "name": "Claude Opus 4.6",
          "limit": { "context": 1000000, "output": 128000 },
          "reasoning": true
        },
        "claude-opus-4-7": {
          "name": "Claude Opus 4.7",
          "limit": { "context": 1000000, "output": 128000 },
          "reasoning": true
        },
        "deepseek-r1-0528": {
          "name": "DeepSeek R1 0528",
          "limit": { "context": 163840, "output": 16384 },
          "reasoning": true
        },
        "glm-5.1": {
          "name": "GLM 5.1",
          "limit": { "context": 202752, "output": 65535 },
          "reasoning": true
        }
      }
    }
  }
}

Get your API key at https://agentrouter.org/console/token

Available models

| Model | Context | Output | Reasoning | |---|---|---|---| | claude-opus-4-6 | 1,000,000 | 128,000 | yes | | claude-opus-4-7 | 1,000,000 | 128,000 | yes | | deepseek-r1-0528 | 163,840 | 16,384 | yes | | deepseek-v3.1 | 163,840 | 32,768 | no | | deepseek-v3.2 | 131,072 | 32,768 | no | | glm-4.5 | 131,072 | 98,304 | yes | | glm-4.6 | 204,800 | 204,800 | yes | | glm-5.1 | 202,752 | 65,535 | yes |

Check https://agentrouter.org/pricing for the latest list.

Usage

  1. Install the plugin (Option A or B above)
  2. Add the provider config with your API key
  3. Restart OpenCode
  4. Run /models and select an AgentRouter model

Development

git clone https://github.com/TVD-00/opencode-agentrouter.git
cd opencode-agentrouter
npm install
npm run build

License

MIT