explaingit

fares-nosair/opencode-agentrouter-support

12JavaScriptAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Local Node.js proxy that lets the OpenCode coding tool talk to AgentRouter models through an OpenAI-compatible adapter. Ships one server file and an opencode.jsonc config.

Mindmap

mindmap
  root((opencode-agentrouter))
    Inputs
      OpenCode chat requests
      AgentRouter API key
    Outputs
      Streamed model replies
      Proxy on port 4000
    Use Cases
      Use AgentRouter models in OpenCode
      Switch between deepseek and glm
      Run a local OpenAI-shape proxy
    Tech Stack
      Node.js
      Express
      OpenAI SDK

Things people build with this

USE CASE 1

Wire AgentRouter as a provider inside the OpenCode editor

USE CASE 2

Pick between deepseek v4 pro, deepseek v4 flash, and glm 5.1 from OpenCode

USE CASE 3

Run a local OpenAI-shape proxy on 127.0.0.1:4000 for other tools

USE CASE 4

Test AgentRouter endpoints with a curl command before wiring an editor

Tech stack

Node.jsExpressOpenAIcors

Getting it running

Difficulty · easy Time to first run · 30min

Needs Node 18+, an AgentRouter API key pasted into the script, and the opencode.jsonc placed in the right per-OS folder.

MIT license, use freely in commercial and personal projects with attribution.

In plain English

This project is a small local helper that lets the OpenCode app use AI models from a service called AgentRouter. OpenCode is a coding tool that expects to talk to AI providers through a specific kind of plugin called the openai compatible adapter. AgentRouter does offer an API in that style, but it does not plug directly into OpenCode. The repository solves the gap with a lightweight Node.js proxy that runs on your own machine and translates between the two. The way the README describes the flow, OpenCode sends a chat request to the proxy on http://127.0.0.1:4000, the proxy forwards it on to AgentRouter, and the streamed reply comes back through the proxy to OpenCode. The proxy is one JavaScript file, agenrouter_server.js, and the OpenCode side is configured by a single config file, opencode.jsonc. The README also includes an ASCII diagram showing this three step path. Setup needs Node.js version 18 or higher and an AgentRouter API key, which the README says has a free tier. You install three npm packages, express, cors, and openai, paste your API key into line 11 of the proxy script, then run the script with node agenrouter_server.js. The expected log line is AgentRouter proxy running on http://127.0.0.1:4000. The opencode.jsonc file goes into the OpenCode config directory, which on Windows is C colon backslash Users backslash your name backslash .opencode and on macOS or Linux is the tilde slash .opencode folder. Once running, you pick AgentRouter as the provider inside OpenCode and choose one of three models the config exposes: deepseek v4 pro, deepseek v4 flash, or glm 5.1. The README provides two curl commands to verify the proxy is up. Customization covers changing the port if 4000 is in use and updating the upstream API base URL if AgentRouter changes their endpoint. The project is released under the MIT license.

Copy-paste prompts

Prompt 1
Walk me through installing express, cors, and openai, pasting my AgentRouter key into agenrouter_server.js, and starting the proxy on Linux
Prompt 2
Copy opencode.jsonc into the right OpenCode config folder for macOS and pick AgentRouter as the provider
Prompt 3
Change the proxy port from 4000 to 4567 in agenrouter_server.js and update opencode.jsonc to match
Prompt 4
Write a curl command that verifies the AgentRouter proxy is serving the chat completions endpoint
Prompt 5
Replace the AgentRouter base URL inside the proxy if the upstream changes their host
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.