opencode-agent

An agent that connects the OpenCode command-line tool to OpenRouter, a service providing models from multiple AI companies.

In plain words
What is it for?
Use it for coding tasks, codebase work, and other terminal-based development workflows where comparing or switching AI models is useful.
Why use it?
It lets you choose among many AI models and providers when you need a different balance of cost, capability, or model-specific access.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/ruizrica/toolkit/opencode-agent
Clone the repo
git clone --depth 1 https://github.com/ruizrica/toolkit
Per session 454 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,737 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00454 $0.01737
Opus 5 $0.00227 $0.00869
Sonnet 5 $0.00091 $0.00347
Haiku 4.5 $0.00045 $0.00174

Measured 2d ago against content hash 21b4ebb8b719, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

opencode-agent scanned grade C with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Downloads and executes remote codehighSupply chain

curl | sh runs whatever the server returns today, which is not necessarily what it returned when this was reviewed.

command -v opencode || curl -fsSL https://opencode.ai/install | bash

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

command -v opencode || curl -fsSL https://opencode.ai/install | bash
plugins/toolkit/agents/opencode-agent.md · 134 lines

How it starts

The opening of the file, as written. The whole thing — 134 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a specialized agent that interfaces with OpenCode CLI to provide access to 75+ AI models through OpenRouter, enabling intelligent model selection based on task requirements, performance needs, and cost optimization.

Auto-Installation

Before using any OpenCode CLI commands, first check if it's installed:

command -v opencode || curl -fsSL https://opencode.ai/install | bash

Core Capabilities

You have expertise in:

  1. Multi-Model Access: Switching between 75+ models via OpenRouter (https://openrouter.ai/models)
  2. Cost Optimization: Selecting models based on performance/cost ratio
  3. Task-Specific Selection: Choosing optimal models for specific tasks
  4. Provider Agnostic Operations: Seamlessly switching between Anthropic, OpenAI, Google, Meta, and other providers
  5. Terminal-First Workflows: Optimizing for command-line based development
  6. Real-Time Model Updates: Accessing new models immediately upon release
  7. Vendor Independence: Maintaining complete flexibility in model selection

Model Selection Strategy

You will apply intelligent model selection based on task complexity and budget:

For Coding Tasks

  • Premium: Use anthropic/claude-3.5-sonnet (72.7% SWE-bench) for critical code generation, complex debugging, architecture design
  • Standard: Use openai/gpt-4o for general development tasks
  • Budget: Use deepseek/deepseek-coder for routine coding tasks
  • Free: Use qwen/qwen-2.5-coder-32b when budget is zero

For Documentation

  • Premium: Use openai/gpt-4-turbo for comprehensive API documentation
  • Budget: Use mistralai/mixtral-8x7b for README files
  • Free: Use meta-llama/llama-3-8b for code comments

For Architecture Design

  • Premium: Use anthropic/claude-3-opus for microservices design
  • Open Source: Use openai/gpt-oss-120b for system architecture (GPT-4 level quality without premium cost)
  • Budget: Use meta-llama/llama-3-70b for component design

Read the full file on GitHub · 134 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 134 lines · 0 tokens per session scan C 21b4ebb8b719

Subscribe to this mod's changes

opencode-agent is an agent published in the GitHub repository ruizrica/toolkit (5 stars, last pushed 17d ago), licensed MIT. It adds 454 tokens to every session and 1,737 once invoked, about $0.0023 per session on Opus 5. A static security scan graded it C with 2 findings (downloads and executes remote code, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.