Case study · August 19, 2026

How to connect Reality Router to OpenCode

60 seconds of config drops OpenCode into RR's routing. On a real 462-request stretch with Opus 5 in the pool, the bill went from $34.10 to $3.70. Same work, 89% off. Full setup, verification, and a real receipt.

Actual bill via RR
$3.70
Same run, no routing
$34.10
Saved automatically
89%

60 seconds of config. On a recent 462-request stretch with Opus 5 in the routing pool, RR cut the bill from $34.10 to $3.70 — same work, 89% off.

If you're running OpenCode as your daily coding agent, one config block turns it into the cheapest, smartest, most measurable agent stack you can run. Every call goes through Reality Router, which does four things at once:

  • Picks the right model per call — RealitySignal calibrated probabilities score every model in your pool against the actual step you're on, so cheap models handle boilerplate and expensive ones only fire when they'll actually help.
  • Kills the token-cap anxiety — pay per token, no weekly limits, no 5-hour windows, no "come back Monday."
  • Gives you a live receipt — every request, every dollar, every fallback lands in a dashboard you own.
  • Works with the OpenCode you already use — no plugin, no fork, same TUI, same /models, same workflow.

Here's the whole setup.


1. Add RR as a provider (30 seconds)

OpenCode doesn't have a GUI flow for custom OpenAI-compatible providers — the /connect command only covers providers in its built-in catalog, and RR isn't in there (yet). So you'll edit the config file directly. Two seconds of code ~/.config/opencode/opencode.json if you're allergic to raw JSON.

Open your OpenCode config — either the global one at ~/.config/opencode/opencode.json or a per-project opencode.json — and drop in this block:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "reality-router": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Reality Router",
      "options": {
        "baseURL": "http://localhost:8000/v1",
        "apiKey": "rr-local"
      },
      "models": {
        "auto":               { "name": "RR Auto (RealitySignal-picked)" },
        "claude-opus-5":      { "name": "Opus 5 via RR" },
        "gpt-5":              { "name": "GPT-5 via RR" },
        "claude-haiku-4-5":   { "name": "Haiku 4.5 via RR" },
        "deepseek-v4-flash":  { "name": "DeepSeek v4 Flash via RR" }
      }
    }
  }
}

That's the exact pattern OpenCode's own docs sanction for any OpenAI-compatible provider — the @ai-sdk/openai-compatible package handles the wire protocol, baseURL points at your RR instance, models populates the /models picker. If RR runs on a different host, swap localhost for that hostname.

Include at least one high-end model in the pool. RR needs both cheap options and something serious to escalate to; without a topline model in reach, it can only route among mid-tier options and your savings will be modest.

2. Pick RR from the model picker (10 seconds)

In the OpenCode TUI:

/models

You'll see Reality Router in the list. Pick auto if you want RR's utility ranker to choose per call — this is what you want 90% of the time. Pin a specific model only if you want to force the choice.

3. Verify it worked (20 seconds)

Ask OpenCode anything trivial:

> what's in the current directory?

Then open the RR dashboard at http://localhost:8000 — you'll see your OpenCode call in the Agent Activity table, tagged with a UA string like opencode/1.18.15 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14. If it's there, you're routed.

What you'll see

Here's the dashboard mid-run:

Reality Router dashboard mid-run: 462 requests, $3.70 actual spend against $34.10 potential, 89% savings, OpenCode as the top consumer in the Agent Activity table.Enlarge

Total Volume: 462 requests. Accrued Expense: $3.70. Potential Cost (if everything had run on the top model in the pool): $34.10. Retained Value: $30.40 — 89% of the bill you'd have paid without routing, saved automatically. The top row of Agent Activity is OpenCode itself.

The dashboard lives at http://localhost:8000 on the machine where RR runs (or http://<your-host>:8000 if you're routing from a different box).

A real OpenCode receipt

Not a demo — one actual workload I ran through this exact setup last week:

  • Task: review a real 100-line diff from psf/requests, produce a structured review with bug flags + questions
  • Wall time: 9m 31s
  • Calls: 20
  • Cost: $0.047

Running the same conversation forced onto the biggest model in my pool would have been an order of magnitude more. RR handed the boilerplate steps (file reads, summarization) to cheap models and reserved the expensive one for the actual review synthesis. I didn't have to think about it.

Why bother

The whole point of running an agent like OpenCode is that it works while you're doing something else — write a spec, walk away, come back to a diff. That only works if you're not white-knuckling the cost meter the whole time.

Connect RR to OpenCode and you can stop rationing. Kick off a long-running agent job — a full codebase audit, a batch refactor, a research crawl — without watching the budget or worrying about a runaway loop torching your subscription cap. RR routes each call to the cheapest model that RealitySignal thinks will actually succeed at that specific step. If something spikes, the dashboard tells you within seconds. No caps, no surprises, no overruns.

Same TUI. Same commands. Same workflow. Just cheaper and safer to let run.

realityrouter.dev


Reality Router is open source and self-hosted. Metrics in this post are from a real 462-request run.