Viro API

Integrations / OpenCode

OpenCode

OpenCode talks to any OpenAI-compatible provider through @ai-sdk/openai-compatible, which is exactly what Viro speaks. There's no plugin to install — just an entry in opencode.json.

Configure

Add a viro provider to opencode.json — project-level, or ~/.config/opencode/config.json for every project:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "viro/viro-optimized",
  "small_model": "viro/viro-gpt-oss-20b",
  "provider": {
    "viro": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Viro",
      "options": {
        "baseURL": "https://api.viro.app/v1",
        "apiKey": "{env:VIRO_API_KEY}"
      },
      "models": {
        "viro-optimized": { "name": "Viro Optimized (router)" },
        "viro-clean": { "name": "Viro Clean (router, renewable-only)" },
        "viro-gpt-oss-20b": { "name": "GPT-OSS 20B" },
        "viro-kimi-k2.5": { "name": "Kimi K2.5" }
      }
    }
  }
}

Set VIRO_API_KEY in your environment — get one from API Keys. OpenCode prefixes every model with the provider name, so viro/optimized becomes viro/viro-optimized — the entries under models above drop that prefix back off before the request reaches us, so the wire value is the real slug (viro/optimized, viro/gpt-oss-20b, etc).

Picking models

OpenCode does not auto-discover models from GET /v1/models — every model you want to select from the OpenCode model picker needs its own entry in the models map above. Call GET https://api.viro.app/v1/models yourself for the current full list rather than assuming one.

model is the default for full agent turns; small_model is what OpenCode uses for cheap background work (summarizing, titling). A router slug (viro/optimized, viro/clean, viro/frontier) is a reasonable default for model — see Model Routing. For small_model a concrete small model like viro/gpt-oss-20b avoids paying for a router decision on trivial calls.

Tool calling

OpenCode's edit/read/bash tools are standard OpenAI-shaped function tools — Viro forwards and returns tool_calls exactly as the SDK expects, same as any OpenAI-compatible client. No special handling needed.

Tool-call reliability varies by model, not by OpenCode — see Server tools for which viro/* models we've verified hold up over long agentic sequences.