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

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

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:

  • Injects identity headers — AgentRouter only allows requests from whitelisted coding-agent clients. The plugin adds the required headers so OpenCode is accepted.
  • Sanitizes Claude request bodies — Strips reasoning_effort, reasoning, and cache_control fields that AgentRouter rejects.
  • 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".
  • Auto-retries on sensitive content errors — When AgentRouter returns sensitive_words_detected, the plugin retries with exponential backoff (up to 30 attempts).
  • Serializes Claude requests — Queues Claude model calls with cooldown to avoid rate limiting.

Requests to all other domains pass through untouched.

Install

{
  "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

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

Development

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

License

MIT

Keywords

opencode

FAQs

Package last updated on 23 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