opencode-cmd-provider
v2.4.2
Published
Command Code provider + plugin for opencode
Maintainers
Readme
opencode-cmd-provider
Use your Command Code plan inside OpenCode.
This plugin connects OpenCode to Command Code and adds every Command Code model to the model picker, so you can use your Go, GOAT, Pro, Max 10×, Max 20×, Provider, Team, or Enterprise plan from OpenCode. It also adds the Rates & usage panel with your plan's allowances, benchmarks, current deals, and live usage — a Command Code section in the terminal's session sidebar, and a Command Code side-panel tab in the OpenCode desktop app.

Disclaimer: This is an unofficial, community-maintained integration. It is not affiliated with, endorsed by, or supported by Command Code. You need your own Command Code account, and Command Code's terms, availability, and pricing apply.
Before you start
- OpenCode installed — opencode.ai.
- A Command Code account and API key — commandcode.ai.
Not sure which OpenCode version you have? Run:
opencode --version- Prints
1.x→ follow Install on OpenCode v1. - Prints
2.x→ follow Install on OpenCode v2.
Using the OpenCode desktop app? It is part of OpenCode v2 — follow Install on OpenCode v2, then see In the desktop app.
Install on OpenCode v1
opencode plugin opencode-cmd-providerRun it inside the project where you want the plugin, or add --global to make
it available in every project:
opencode plugin opencode-cmd-provider --globalThat one command adds the plugin to your OpenCode configuration, registers Command Code and all of its models, and adds the sidebar section. Restart OpenCode when it finishes.
Install on OpenCode v2
OpenCode v2 uses a different command — note the add:
opencode plugin add opencode-cmd-providerThis adds the plugin to your global OpenCode configuration, so it works in every project, registers Command Code and all of its models, and adds the sidebar section. Reload OpenCode when it finishes:
opencode reloadClosing and reopening the TUI is not enough on v2 — the background service keeps
the previously loaded plugin. If the plugin still does not appear, restart the
service with opencode service restart.
In the desktop app
The desktop app picks up the same install. Quit and reopen the app after
installing: its windows load the plugin when they start, so an open window
keeps running without it. Once reopened, the [CMD] models are in the model
picker and the Command Code side-panel tab is available — see
The panel in the desktop app.
If an install command fails on your machine, you can add the plugin to your configuration by hand — see Installation mechanics in the technical reference.
Connect your Command Code account
OpenCode v1: sign in from the browser
In OpenCode, run:
/connectSelect Command Code in the provider list, then pick how to sign in:
- Command Code — the browser flow. Finish the sign-in in your browser; the key is stored by OpenCode and reused from then on. Take your time: the plugin waits up to five minutes for the browser to hand the key back, so there is no rush picking an organization or approving access.
- Command Code API key — paste the key the Command Code studio shows you.
Use this when the browser cannot reach OpenCode's
localhostcallback, for example when OpenCode runs on a remote host.
OpenCode v2: use your API key
OpenCode v2 has no browser sign-in for Command Code. Set your API key before starting OpenCode:
export COMMANDCODE_API_KEY="user_..."Or run /connect inside OpenCode and paste the key when asked.
Already signed in with the Command Code CLI?
If you ran cmd login, OpenCode reuses that login automatically, so you may not
need to connect at all. The plugin reads it from ~/.commandcode/auth.json.
This does not cover COMMAND_CODE_API_KEY, the variable the Command Code CLI
documents for CI and headless use. This plugin reads COMMANDCODE_API_KEY
instead. Set that one, or run /connect.
Start using it
- Pick a model: run
/modelsand choose any entry starting with[CMD], for example[CMD] Claude Sonnet 5. - Start chatting. Your Command Code plan handles the requests.
Prefer the command line? Run a single prompt without the interactive interface:
opencode run --model commandcode/claude-sonnet-5 "hello"What you get
The Rates & usage panel
While a session uses a [CMD] model, OpenCode shows the Rates & usage
panel (titled Command Code) for that model — in the sidebar of the
terminal interface, and in the side panel of the desktop app:
- Tier and status of the model
- Allowance — the monthly allowance on each plan
- Rates — input, output and cache rates per million tokens, including peak/off-peak and context-window bands where Command Code publishes them
- Other Information — benchmark scores, current deals and
was/nowrates - Usage — your live 5-hour, weekly and monthly usage, and this cycle's requests, tokens and spend, refreshed as you work
The panel in the terminal
To show, hide or reorder segments, type /cmd-rates-usage in the prompt (or
run Show, hide and reorder sidebar content from the command palette,
ctrl+p). Toggle the sidebar with ctrl+x b.
The panel in the desktop app
Open a session that uses a [CMD] model, then open the Command Code tab
either way:
- the + menu beside the side-panel tabs, or
- Show Command Code rates and usage in the command palette.
Both are offered only while the session's model is a Command Code one; switch to another provider's model and they disappear until you switch back. Usage refreshes after each completed turn, and the refresh button in the panel's header fetches it again on demand.
The desktop tab always shows every segment in the default order. Showing,
hiding and reordering segments (/cmd-rates-usage) is available in the
terminal interface only for now.
Plan and deal summaries
Ask OpenCode something like "Which Command Code plan am I on?" or "How many
requests does my Command Code plan cover this month?" and it uses the built-in
cmd_plan_summary tool: the plan and account the current credential resolves
to (or the plan you pinned), its allowances and the current deals, turned into
an estimate. The summary says which credential and account it answered for.
To force a plan instead of detecting it, add it to the question (for example
plan=pro) or set COMMANDCODE_PLAN=pro before starting OpenCode. A pinned
plan is marked (pinned) in the summary.
Everyday details
- Reasoning models show their effort levels in OpenCode, so you can pick how hard the model should think.
- Vision models accept image input; text-only models will tell you instead of silently ignoring the image.
- Costs shown in OpenCode are estimates from Command Code's published
pricing, and some models show
$0because no price is published for them. Check the current Command Code pricing before relying on the numbers. - Transient failures are retried. A dropped connection or a temporary server error is replayed a couple of times before OpenCode sees a failure, so a blip does not end your turn. Permanent answers — a usage-window limit, a rejected request — come straight back as errors, and a turn that already streamed text is never replayed.
Your data
The plugin talks only to Command Code: your prompts, the background model-list
refresh, and the usage lookups for the sidebar panel. It sends nothing anywhere
else. To ask Command Code for zero data retention, set CMD_ZDR=1 before
starting OpenCode, as you would for the Command Code CLI.
Keep it up to date
A new release only reaches you after OpenCode refreshes its cached copy of the plugin.
OpenCode v2:
opencode plugin updateThen run opencode reload, and quit and reopen the desktop app if you use it.
OpenCode v1: delete the cached copy and restart OpenCode:
rm -rf ~/.cache/opencode/packages/opencode-cmd-provider*The first start after an update takes a little longer because the plugin is downloaded again. You never need to sign in again.
New Command Code models usually appear on their own: the plugin refreshes its
model list in the background each time OpenCode starts, so a model launched
after your installed version was published reaches /models on the next plugin
load. On OpenCode v2, run opencode reload (or opencode service restart)
first — closing and reopening the TUI does not reload the background service.
If the model is still missing, the background refresh may be blocked by your
network or disabled via COMMANDCODE_DISABLE_CATALOG_SYNC; updating the plugin
is then the fix.
Uninstall
OpenCode v2:
opencode plugin remove opencode-cmd-providerOpenCode v1: remove opencode-cmd-provider from the plugin list in your
opencode.json (and from tui.json if it is listed there).
Then remove the cached copies to free the space — the plugin package
(npm on v2, packages on v1) and the plugin's saved model list:
rm -rf ~/.cache/opencode/npm/opencode-cmd-provider* ~/.cache/opencode/packages/opencode-cmd-provider* ~/.cache/opencode-cmd-providerThe provider and models this plugin registered disappear with it. Quit and reopen the desktop app, if you use it, to remove the Command Code tab.
Troubleshooting
| What you see | What to try |
| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| No [CMD] models in /models | Check that your API key is set (or that /connect succeeded), then reload OpenCode (opencode reload, or opencode service restart on v2). Update the plugin if your install is old. |
| A newly released model is missing from /models | The catalog refresh applies on plugin load. On v2, run opencode reload (or opencode service restart) — restarting the TUI alone keeps the old plugin loaded. |
| Some Command Code models in /models lack [CMD] | Update the plugin. On OpenCode v2, older versions kept models.dev's own names for the models it also lists. |
| The sidebar has no Command Code section | Make sure the session uses a [CMD] model, and press ctrl+x b — the sidebar may be hidden. |
| The desktop app has no Command Code tab | Make sure the session uses a [CMD] model, then open the tab from the + menu or the command palette. If neither offers it, quit and reopen the app after installing or updating. |
| Browser sign-in fails (v1) | Run /connect again and pick Command Code API key to paste one, or set COMMANDCODE_API_KEY and restart OpenCode. |
| HTTP 404 on every request | Check provider.commandcode.options.baseURL. Set it to https://api.commandcode.ai — the plugin appends /provider/v1/… itself — or remove it. |
| Your API key has expired, but the key works | A 401 now names the credential it used. If it says legacy file ~/.commandcode/auth.json, that login is stale — reconnect or set COMMANDCODE_API_KEY. |
| A model shows $0 cost | No published price for that model, so the estimate is 0. See Command Code pricing. |
| Command Code rejected this plugin as out of date | Command Code refuses the version your install reports. Update the plugin — see Keep it up to date. |
| Something else | See the technical reference or open an issue. |
Learn more
- Technical reference — how the plugin works, where the model and deals data comes from, and the decisions behind it. Most useful sections: Environment variables, Installation mechanics and caching, and Troubleshooting.
- CHANGELOG.md — what changed in each release.
- CONTRIBUTING.md and RELEASE.md — for contributors and maintainers.
Credits
Inspired by pi-commandcode-provider.
License
MIT
