OpenCode + RelayPlane: Cost Tracking Without Code Changes
OpenCode supports a custom baseURL in opencode.json. Point it at RelayPlane on localhost:4100 and every LLM call is logged to local SQLite with exact cost, token count, and model. No code changes. No cloud account. One config line.
TL;DR
Add RelayPlane to OpenCode when you want:
- Per-request cost tracking across every OpenCode session
- Automatic routing of simple tasks to cheaper models
- Hard budget caps that stop requests before you overspend
- Local SQLite dashboard at localhost:4100 with all data on-device
OpenCode alone is enough when:
- You only need AI coding assistance and do not track spend
- You have a fixed model subscription and cost per call does not matter
- You want zero additional processes running locally
Feature Comparison
| Feature | RelayPlane | OpenCode alone |
|---|---|---|
| Product focus OpenCode is a terminal-based AI coding tool. RelayPlane is a local proxy that sits between OpenCode and the model providers, logging every request cost to SQLite and routing by task complexity. They are complementary: OpenCode generates the requests, RelayPlane governs what they cost. | Cost intelligence + complexity routing proxy | Terminal AI coding assistant |
| Custom baseURL support OpenCode supports setting a custom baseURL for any provider in opencode.json. Setting "baseURL": "http://localhost:4100" routes all LLM calls through RelayPlane automatically. No code changes and no plugin required. | Accepts all OpenAI-compatible traffic | Per-provider baseURL in opencode.json |
| Per-request cost tracking RelayPlane logs the exact token count and dollar cost of every request to local SQLite. Without it, OpenCode users have no native way to see what each coding session costs across multiple model calls. | SQLite per-request log (on-device) | No built-in cost dashboard |
| Complexity-based routing RelayPlane automatically routes simple tasks to cheaper models like Haiku and complex tasks to Opus based on request complexity. OpenCode sends each request to whichever model the user has configured, with no automatic cost optimization. | ||
| Budget caps and spend controls RelayPlane enforces configurable budget caps that stop requests before you overspend. OpenCode does not provide budget enforcement: once a session is running, there is no mechanism to halt requests when spend exceeds a threshold. | ||
| Local cost dashboard RelayPlane provides a local dashboard at localhost:4100 showing per-request spending, model distribution, and token usage across all OpenCode sessions. The data is stored in local SQLite and never leaves your machine. | localhost:4100 (on-device) | None |
| Data privacy When RelayPlane is in the path, requests still go directly to the model provider. RelayPlane only logs metadata (tokens, cost, model, latency) to local SQLite. No prompt content is stored by RelayPlane. | All cost data stays on device (SQLite) | Requests go directly to model providers |
| No account required RelayPlane requires no account. OpenCode itself is open source and requires no account, but you still need API keys from each model provider you use. | Depends on providers | |
| npm package Both tools install as global npm packages. OpenCode had 217,587 weekly downloads at the time of writing. RelayPlane adds cost intelligence on top of whichever providers OpenCode talks to. | npm install -g @relayplane/proxy | npm install -g opencode-ai |
| Open source Both RelayPlane and OpenCode are MIT licensed. No vendor lock-in on either side. | MIT | MIT |
| Works without RelayPlane OpenCode works perfectly without RelayPlane. Adding RelayPlane adds cost tracking, complexity routing, and budget controls on top of any OpenCode workflow. It is purely additive. | N/A | |
| Setup complexity To add RelayPlane to an existing OpenCode setup: install @relayplane/proxy, run relayplane start, and add one line to opencode.json. Total time under two minutes. | One npm install + one config line | One npm install |
Why OpenCode Users Add RelayPlane
One config line. Instant cost visibility.
OpenCode already supports a custom baseURL for every provider in opencode.json. That means adding RelayPlane to an existing OpenCode workflow requires zero code changes. Install @relayplane/proxy, run relayplane start, then set "baseURL": "http://localhost:4100" in your opencode.json. Every subsequent LLM call is logged to local SQLite with token counts and exact dollar cost. The first time you see how much a single OpenCode session costs, you understand why the one-line setup is worth it.
Complexity routing cuts OpenCode spend automatically
OpenCode fires many LLM requests in a single session: short file reads, large refactors, multi-file diffs. Without routing, all of those requests hit the same model regardless of complexity. With RelayPlane in the path, simple requests are automatically routed to cheaper models like Haiku while complex ones go to Opus. The routing decision happens per-request with no configuration required beyond pointing baseURL at localhost:4100. For developers running long OpenCode sessions, the cost difference compounds across dozens of calls.
Budget caps stop runaway sessions before they bill
A single OpenCode session on a complex codebase can generate dozens of large-context requests. Without a spend limit, it is easy to accumulate unexpected costs across a working day. RelayPlane lets you set hard budget caps by session, by day, or by project. When the cap is hit, requests stop. This is not a cloud-side throttle: the enforcement happens locally before the request leaves your machine, so you pay nothing for requests that would have exceeded the cap.
MIT open source with no cloud dependency on either side
OpenCode is MIT licensed and runs entirely on your machine. RelayPlane is also MIT licensed and runs entirely on your machine. Adding RelayPlane to your OpenCode setup introduces no new cloud dependency, no third-party service in the request path, and no data leaving your device beyond the API calls OpenCode was already making. The cost log in local SQLite is yours to query, export, or delete at any time.
OpenCode Handles the Coding. RelayPlane Handles the Cost.
OpenCode is a fast-growing terminal AI coding tool with over 200,000 weekly npm downloads. It supports custom provider endpoints natively: any provider in opencode.json can have its baseURL overridden, which means pointing it at a local proxy requires zero changes to how OpenCode itself works.
RelayPlane takes advantage of that flexibility. Install it once, start it once, add one line to opencode.json, and every LLM call OpenCode makes is now logged to local SQLite with the exact model, token count, and dollar cost. The data never leaves your machine. There is no cloud account, no API key to manage for RelayPlane itself, and no monthly fee. It is a purely additive layer that gives you the cost visibility OpenCode does not include on its own.
Add RelayPlane to OpenCode in Under 2 Minutes
Step 1: Install and start RelayPlane
Step 2: Add one line to your opencode.json
Done. Every OpenCode LLM call now routes through RelayPlane and is logged to local SQLite. View the dashboard at localhost:4100.