Command Code API provider for opencode. Use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, Step, and other models through a single API key.
This plugin is for Command Code accounts with Provider API access. GOAT is the live-tested baseline; other accounts can use models they're entitled to. The $1 Go plan's monthly allowance does not cover Provider API requests, but Go users can call the API with eligible free or purchased credits. The catalog follows the provider-wide model list, so a model appearing in OpenCode does not imply that every account can call it. See the Go plan's API support and Provider API docs.
This package keeps a bundled model catalog current via CI. You do not need a local command-code CLI. Catalog patches publish automatically after a green PR merges to main.
Previously published as @brainervirus/commandcode-go-opencode-provider. Use this name instead.
This package is based on FanFan4204/opencode-commandcode-provider. That work started from brent-weatherall/opencode-commandcode-provider by Brent Weatherall. Thank you both — FanFan for the OpenCode provider this repo continues, and Brent for the original plugin, catalog extraction.
- Bundled
models.jsonis the default runtime catalog (no local CLI scrape). - V1 and V2 use their native plugin and provider surfaces. V1
server()fillsprovider.commandcodeand registers API-key auth; V2setup()registers provider/model transforms and a key/env integration for/connectandopencode auth login. - Validation at the boundaries via
src/schemas.ts(zod): bundledmodels.json/manifest.jsonreads, provider availability payloads, and the plugin config file. - CLI cost extraction can fail without dropping models; official docs fill missing costs, remaining paid gaps use models.dev as a reference price at sync time. Command Code free SKUs stay
$0. - The Provider API accepts text and images only. The bundled catalog advertises image input only when the CLI catalog or a matching models.dev entry lists it. It does not advertise audio, video, PDF, or other file inputs.
- Reasoning effort variants on models that declare
reasoningEfforts. - Release date, family, input limits, model status, vendor context limits, and matched context-price tiers flow through the bundled catalog. V2 gets native release, family, input, status, and tier fields; V1 keeps its supported fields and base prices, with
context_over_200kwhere representable. - Routing uses each model's
supported_endpoints. Claude uses Anthropic Messages when advertised. Other models use Chat Completions whenever advertised, even if they also advertise Messages or Responses. Outside the Claude preference, Chat Completions is preferred whenever advertised; if only Messages and/or Responses are advertised, Messages is preferred when available, otherwise Responses. Without endpoint metadata, Claude defaults to Messages and other models default to Chat Completions. This keeps DeepSeek V4.1 Flash#maxon the previously verified Chat Completions tool-call path on V1 and V2. Claude Sonnet 4.6 returnedMODEL_NOT_IN_PLANon the tested GOAT account; entitled Claude access has not been live-verified. If an entitled model fails, please open an issue with the model ID and OpenCode version. - Quiet OpenCode startup (diagnostics go to
startup.json, not stdout). - Free models show
(Free)after their display name on V1 and V2 when all catalog prices are zero. Model IDs and routing stay unchanged; this is a name suffix, not a native desktop badge. Names that already end inFreeor(Free)keep their existing label. - Zero data retention on request:
CMD_ZDR=1orzdr: truein the plugin config addsx-cmd-zdr: 1to every Command Code Provider API (/provider/v1/*) request on both OpenCode generations.
For published plugin versions, the six-hour CI schedule extracts the latest command-code npm bundle and refreshes callable models plus endpoint metadata, even when the CLI version is unchanged. It opens a catalog PR only when generated artifacts change; at startup the plugin loads those artifacts and registers them with OpenCode — never the other way around.
- Extract + filter — model entries (ids, names, reasoning,
inputModalities, limits) are evaluated out of the minified CLI bundle (src/catalog.ts), then intersected with the callable IDs reported by the provider API. - Metadata + costs merge — vendor context length tightens only a fallback context limit, and missing endpoint metadata preserves the last known route data. models.dev contributes release date, family, input limit, status, vision metadata, and cost tiers when present. Tier rows are accepted only when their base prices match this Command Code catalog. Base costs use CLI bundle → official Command Code docs → free SKUs (
$0) → models.dev reference prices → unmatched placeholder. Anything still unmatched marks the catalogdegraded. This runs at sync time only; runtime never fetches metadata or prices. - Artifacts —
models.json(the catalog),_version.txt(upstream version),manifest.json(counts, per-source cost stats,healthy/degraded/brokenstatus). - Version-specific registration — V1 uses the
pluginconfig key, direct AI SDK packages, theserver()provider map, and its auth callback. V2 usesplugins, OpenCode's native provider runtimes, provider/model transforms, and acommandcodeintegration with key andCOMMANDCODE_API_KEYenvironment methods. Both retain the Command Code wire model ID. V2 exposes tiered context pricing; V1 emits its supportedcontext_over_200kfield and keeps flat pricing for other tiers. - Degraded/cache fallbacks — a
degraded/brokenmanifest sets the degraded flag with a reason; an unreadable bundledmodels.jsonfalls back to the last-good cache; auth/connect still registers even with an empty catalog.
OpenCode V2:
{
"plugins": ["@brainervirus/opencode-commandcode"]
}OpenCode V1:
{
"plugin": ["@brainervirus/opencode-commandcode"]
}The bare package name is unpinned and resolves npm's latest release when OpenCode installs or updates it; adding @latest is unnecessary. OpenCode V2 checks for updates at startup but keeps an existing cached package. Apply a newer package with OpenCode's plugin-update action, then restart to load it. OpenCode V1 can refresh the global package with opencode plugin @brainervirus/opencode-commandcode --global --force.
file:// checkouts are not updated by npm; git pull after CI commits, or switch to the npm plugin line.
On OpenCode V2 the plugin registers the commandcode provider, its models, the native OpenCode runtime, and its API base URL through the V2 provider API. On V1 the server hook fills provider.commandcode defaults — npm: "@ai-sdk/openai-compatible" plus the Provider API baseURL; the plugin package itself is never the SDK npm field. Only add a manual provider entry if you need non-default transport options.
Set COMMANDCODE_API_KEY, or connect interactively. OpenCode V1 provides Command Code through /connect; OpenCode V2 registers key and environment methods for /connect and opencode auth login commandcode. V2 uses OpenCode's automatic provider activation and preserves an explicit activation setting. Connect before running a model; an explicit run while disconnected still returns an authorization error from the API.
/models
Catalog patches ship in new npm releases. OpenCode loads the version in its package cache; an update must be applied through the host before the new catalog appears. If a new model is missing after an announced sync, check the installed package version, apply the update, and restart OpenCode.
Optional, ~/.config/opencode/opencode-commandcode.json (legacy fallback name commandcode-go-opencode-provider.json still loads). Unknown keys are ignored; every field has a default, and an invalid field falls back on its own without discarding the valid ones (an invalid zdr value keeps ZDR on).
| Key | Default | Effect |
|---|---|---|
commandCodePackagePath |
"" |
Maintainer override: extract the catalog from a local command-code checkout instead of the bundle. Same as env COMMANDCODE_PACKAGE_PATH. |
debugStartupLogs |
false |
Also mirror the startup summary to stderr. Default is quiet (startup.json only). |
disableModelSync |
false |
Accepted for forward compatibility; currently has no effect. |
zdr |
false |
Send x-cmd-zdr: 1 on every Provider API request (zero data retention). Same as env CMD_ZDR=1. A present but invalid value (e.g. the string "true") counts as on. |
Command Code enforces zero data retention with the
x-cmd-zdr: 1 request header; the CLI exposes the same opt-in as CMD_ZDR=1. This plugin never invoked the CLI, so
set either:
- env
CMD_ZDR=1(accepts1,true,yes,on; case-insensitive), or "zdr": truein~/.config/opencode/opencode-commandcode.json.
The plugin then adds the header to every Command Code Provider API (/provider/v1/*) request: V2 registers it on the
commandcode provider, V1 on the provider options.headers. A ZDR header you configure yourself
(providers.commandcode.headers on V2, provider.commandcode.options.headers on V1) wins over the plugin's value.
Header names are matched case-insensitively, and the plugin collapses any spelling (X-Cmd-Zdr) into a single lowercase
x-cmd-zdr key, so a request never carries two ZDR headers. Custom npm transports keep owning their options.
Behavior to expect from the API: when set, requests route only through ZDR-capable upstreams, and a model without one
fails with 422 cmd_zdr_no_providers instead of falling back to a non-ZDR provider. Free models are not ZDR-routed;
choose a model with ZDR coverage rather than relying on a (Free) SKU for ZDR. ZDR can change which upstream
serves a request, so it may cost more. The header is sent on the Chat Completions, Messages, and Responses routes alike;
live verification so far covers Chat Completions only.
The programmatic SDK factory (createCommandCode) calls /alpha/generate, which the ZDR documentation does not cover,
so it fails closed: with ZDR requested (CMD_ZDR on, or an x-cmd-zdr: 1 header in any casing),
languageModel() throws before any request is sent. An explicit x-cmd-zdr: 0 header opts the SDK out of CMD_ZDR.
Live verification against the Provider API lives in tests/integration/zdr.integration.test.ts and is skipped unless
COMMANDCODE_API_KEY is set:
COMMANDCODE_API_KEY=... bun run test:integrationMaintainers only. OpenCode will scrape a local command-code install when COMMANDCODE_PACKAGE_PATH or commandCodePackagePath in ~/.config/opencode/opencode-commandcode.json is set.
Open a bug report for install, auth, catalog, or model-call failures — include the failing model ID, the exact error, and your plugin and OpenCode versions.
This repository does not accept directory, "awesome list", plugin-marketplace, or outreach submissions. Issues opened for that purpose are closed without review.
git clone https://github.com/BrainerVirus/opencode-commandcode.git
cd opencode-commandcode
bun install
bun run check # oxlint + oxfmt --check + bun test tests/unit/ + tsc (the release gate)bun run sync -- --remote # refresh models.json + manifest.json + _version.txt from command-code@latest
bun run build # bundle src/entry.ts to dist/plugin.js
bun test tests/unit/ # unit suite (also via bun run test)
bun run test:integration # live-endpoint tests, not part of the gate
bun run verify:release-candidate # dry-run pack; manifest and package versions must match
bun run generate-readme # reports catalog counts only; README is hand-edited
bun run catalog:ci # entry used by the catalog-sync workflowEntry points: plugin.ts owns both config surfaces (V2 id/setup plus V1 server); index.ts re-exports the plugin plus the createCommandCode SDK factory; src/entry.ts is bundle glue for scripts/build-plugin.ts only — it produces dist/plugin.js.
CI (.github/workflows/catalog-sync.yml) checks every 6 hours for CLI catalog changes and provider availability/endpoint metadata changes; it opens a fix(catalog) PR only when generated files change. If extraction fails or the model-count safety floor is breached, it opens a catalog-break issue and leaves the last-good files intact. The PR auto-merges after check (test), check (typecheck), check (lint), check (format), and check (pack) are green. .github/workflows/release.yml then runs semantic-release (build + verified npm publish via OIDC trusted publishing + GitHub Release + tag). Do not push to main.
Publishing uses npm trusted publishing (OIDC): the release workflow requests id-token: write, setup-node does not set registry-url, and no long-lived npm token is stored. Configure the package's trusted publisher once with scripts/setup-npm-trusted-publishing.sh (repository BrainerVirus/opencode-commandcode, workflow release.yml; requires npm with --allow-publish, and the script falls back to npx npm@11.21.3 on older npm). Classic npm tokens were revoked in December 2025 and granular write tokens expire within 90 days, so do not reintroduce NPM_TOKEN. Catalog PRs get a real CI run when RELEASE_SYNC_TOKEN is a PAT; GITHUB_TOKEN can open the PR but GitHub will not start workflows from that event.
MIT — see LICENSE. Original copyright Brent Weatherall.