@r-33/opencode
v0.5.2
Published
The Route 33 plugin for OpenCode: sign in with your browser, assign the budget for usage, and use the route_33 models — no API keys to paste, ever.
Readme
@r-33/opencode
The Route 33 plugin for OpenCode: sign in with your browser, assign the budget for usage, and use the route_33 models — no API keys to paste, ever.
Install
OpenCode v2 (recommended):
opencode plugin add @r-33/opencodeInstalls globally — one plugins entry in the config's opencode.json
loads every part (the server and TUI parts are auto-discovered from the
package exports; no tui.json exists on v2).
OpenCode v1:
opencode plugin @r-33/opencode # project scope (default)
opencode plugin @r-33/opencode --global # global scopeInstalls at the nearest definition and registers the plugin twice: the
server part in opencode.json and the TUI part in tui.json — both files
are load-bearing on v1, which is why the installer writes both.
Either way, restart OpenCode afterwards — plugins load at startup. Prefer
config? Declare the plugin directly in opencode.json(c):
{ "plugin": ["@r-33/opencode"] }First run
With ROUTE33_API_KEY unset, a fresh install starts silent: nothing opens
until you connect — run /connect, type route33, and press Enter on the
sign-in dialog to open the link in your browser (or c to copy it). Once
the connect completes, the wizard takes over automatically:
- Run
/connectand choose Route 33 — press Enter to open the sign-in link and finish the browser sign-in. - The budget picker follows in OpenCode — your organisations come first when you belong to several (budgets never mix organisations), then that organisation's projects or your personal key.
- Key setup follows for that budget: bind one of your existing keys for it, or create one — name, monthly cap in EUR, description, expiry, and the models it may use (tick several, or allow all).
- The route_33 models appear. Pick one and prompt away — OpenCode v2 asks you to pick when no route_33 model is active yet.
The cap is checked against what the budget allows you: the question shows the maximum when the budget sets one, and asks again for a higher amount. Binding a key whose secret is not stored on this machine rotates it — its other users stop working — so you are asked first. Esc on any question cancels the setup; nothing is created.
On OpenCode v2 the setup is blocking: a waiting dialog covers the pauses
between the steps until the key exists, and a key Route 33 still refuses
shows the reason and returns to the questions with your answers kept. The
model pick switches the model inside a session; from the home screen it
ends with a pointer to /models.
A folder that is signed in but never attributed auto-runs the budget
picker at launch — the prompt stays locked behind a setup mode until a
budget is assigned, with Enter resuming setup; route_33 model requests
from unattributed folders are refused server-side where the lock is
unavailable. A message never names both commands: it points to /connect
while you are signed out, and to the /r33 menu once you are signed in. A
browser is required for every sign-in; restarts afterwards sign in
silently.
On OpenCode v1
The flow is the same; a few things differ:
/connectlists Route 33 asroute_33. Its sign-in dialog shows the link: open it, or presscto copy it.- Until a folder has its budget, the model list shows one route_33 entry,
"Not set up yet" — it only keeps Route 33 in
/connect. - A budget needs a Git repository. Outside one, use
ROUTE33_API_KEYor OpenCode v2. - To sign out, run
opencode auth logoutand choose Route 33.
Commands
| Command | Effect |
| -------------- | ------------------------------------------------------------------- |
| /r33 | Open the Route 33 menu |
| /r33 inspect | Show the assigned budget, the active key, and its rotation state |
| /r33 rotate | Rotate the key immediately |
| /r33 reset | Clear the assigned budget — the wizard runs again on the next start |
To sign out, run /connect, choose Route 33, select your account and press
Ctrl+D twice. Once the last account is removed, the plugin forgets its
sign-in on this machine; your key and budget stay.
The menu's budget entry — Attribute on OpenCode v2, Change budget on v1 — reopens the budget picker and the key setup for this folder.
A browser is required for every sign-in; restarts afterwards sign in silently.
Keys
One key per workspace: each project folder uses its own Route 33 key, and every request carries the key of its own workspace — connecting another folder never changes who this one bills for. Keys are short-lived and rotate automatically; nothing secret is ever written to your project, logs, or terminal.
Outside a Git repository a folder has no budget of its own: /connect
offers your personal key, and that one choice covers every such folder on
this machine. To change it, open /r33: Attribute in such a folder,
Global key inside a repository.
Session cost
The cost OpenCode shows for a session on a route_33 model is an estimate from USD list prices. Route 33 meters your budget itself, in EUR — the two differ, and a model without a published price shows no cost.
Direct key mode
Set ROUTE33_API_KEY to a gateway key and the wizard is bypassed entirely —
no sign-in, no attribution pick, no browser, no per-workspace keys. This is
the right choice for autonomous, headless, or remote sessions where no human
is present or the machine has no browser. Key rotation is your responsibility.
export ROUTE33_API_KEY=r33_sk_...Auto-connect
Connecting is always explicit — run /connect yourself. What auto-starts
at OpenCode launch is the attribution wizard for folders that are signed
in but have no budget assigned yet. Suppress that with
ROUTE33_AUTOCONNECT=0 and assign the budget from the /r33 menu when
you choose to; on OpenCode v1 the opt-out switches the /r33 menu off as
well. On remote or headless machines, use ROUTE33_API_KEY instead of the
wizard.
Troubleshooting
| Symptom | What to do |
| ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| No route_33 models after start | /connect → Route 33 — the silent sign-in expired; sign in once and they return |
| "This Route 33 build has no OAuth client id" | Update the plugin to a released build, or set ROUTE33_CLIENT_ID and restart |
| Sign-in link never appears / SSH-only machine | Sign-in needs a browser on the same machine — there is no device-flow fallback |
| "Route 33 — key not created" (OpenCode v2) | The dialog gives Route 33's reason, such as a cap above your allowance — change the answer and confirm again |
| "Choosing individual models needs a fresh Route 33 sign-in." | A personal budget lists its models only for a sign-in that carries the models:read permission; the next browser sign-in adds it |
Configuration
| Variable | Purpose | Default |
| --------------------- | -------------------------------------------- | -------------------------------- |
| ROUTE33_API_KEY | Pre-shared gateway key (bypasses the wizard) | not set (wizard mode) |
| ROUTE33_AUTOCONNECT | Opt out of the auto-start wizard | 1 (auto-start enabled) |
| ROUTE33_CLIENT_ID | OAuth client identifier | included in released builds |
| ROUTE33_AUTH_ISSUER | OAuth issuer | https://auth.route33.ai |
| ROUTE33_API_BASE | Management API base | https://mapi.route33.ai/api/v1 |
| ROUTE33_BASE_URL | Gateway models base | https://api.route33.ai/v1 |
A custom ROUTE33_CLIENT_ID must allow every scope the plugin requests —
models:read, which lists the models of a personal budget, among them —
or the auth server refuses the sign-in with invalid_scope.
