Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

opencode-agentrouter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencode-agentrouter

OpenCode plugin to use models from agentrouter.org

Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
13
-45.83%
Maintainers
1
Weekly downloads
 
Created
Source

opencode-agentrouter

OpenCode plugin that lets you use AgentRouter models inside OpenCode.

AgentRouter provides access to Claude Opus, DeepSeek, GLM and other models through a unified API. This plugin handles the authentication handshake so OpenCode can connect without being blocked.

How it works

AgentRouter validates incoming requests against a whitelist of known coding-agent clients. Raw API calls are rejected with "unauthorized client detected". This plugin patches globalThis.fetch to inject the required client identity headers into every request targeting agentrouter.org — making OpenCode appear as an authorized client.

Install

Add to your OpenCode config (~/.config/opencode/opencode.json or opencode.json):

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

OpenCode installs npm plugins automatically at startup.

Option B: local plugin

Copy dist/index.js into your plugins directory:

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

Files in the plugins directory are auto-loaded — no config needed.

Configure provider

Add the AgentRouter provider to your OpenCode config:

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

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

Available models

ModelContextOutputReasoning
claude-opus-4-61,000,000128,000yes
claude-opus-4-71,000,000128,000yes
deepseek-r1-0528163,84016,384yes
deepseek-v3.1163,84032,768no
deepseek-v3.2131,07232,768no
glm-4.5131,07298,304yes
glm-4.6204,800204,800yes
glm-5.1202,75265,535yes

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

Usage

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

How the plugin works

The plugin runs at module load time and patches globalThis.fetch. For any request to agentrouter.org, it injects headers that identify the caller as an authorized coding-agent client. Requests to all other domains pass through untouched.

No API keys are stored or transmitted by the plugin itself — it only adds identity headers. Your API key is managed by OpenCode's provider config as usual.

Development

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

License

MIT

Keywords

opencode

FAQs

Package last updated on 22 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts