@opencode/cli (v2.3.0, selected stable release as of 2026-11-16).
Upstream is github.com/anomalyco/opencode. The old opencode-ai package
tracks the 1.x line and does not select OpenCode 2.
Install
latest OpenCode tool to this exact
release before computing build inputs. Explicit V2 pins and locked tool selections are preserved. V1 pins or locks
are refused with an upgrade message. Existing images using an older installer policy are reprovisioned through
the normal crew build path when next needed. The build rejects OpenCode 1.x
binaries before publishing a ready image. The build toolchain inventory records the observed version.
Each run uses --standalone so a background OpenCode server cannot supply
configuration or credentials from another invocation.
Crewship generates native V2 providers.<id>.settings overrides and uses
@opencode/ai/providers/openai-compatible for custom compatible endpoints.
Go, Zen and Z.AI Coding Plan retain their native provider packages. MCP files
currently use OpenCode 2’s supported legacy-config normalization.
Auth (BYOK across providers)
OpenCode reads provider credentials from env vars based on whichprovider/model you pick. Crewship’s apiKeyEnvVarsForAdapter("OPENCODE") accepts:
Add any of the above as a
SECRET-type credential and assign to your OpenCode agent.
Models
OpenCode requiresprovider/model namespaced strings (NOT bare IDs). Curated picker entries — opencode/ rows bill through a Zen account, opencode-go/ through a Go subscription, zai-coding-plan/ through a GLM Coding Plan:
Command shape
--format json (NOT --output-format) emits JSONL events.
MCP
Configured at/output/<slug>/opencode.json:
- Top key is
mcp(NOTmcpServers) type: local(stdio) orremote(HTTP/SSE)commandis an ARRAY (binary + args together)- env field is
environment(NOTenv) - Each entry carries
"enabled": true - Env-var syntax is
{env:VAR}(NOT${VAR}) — Crewship translates standard${VAR}form on write
Crewship auto-injects two sidecar-hosted servers under
mcp (injectMemoryMCP + injectRoutinesMCP): crewship-memory and crewship-routines, both type: remote pointing at http://127.0.0.1:9119/mcp/memory/<slug> and .../mcp/routines. A user-declared server of the same name wins.Memory
AGENTS.md is OpenCode’s auto-discovered system instructions file. Crewship writes it as part of the canonical memory set. For turn-1 parity (OpenCode discovers AGENTS.md on the second invocation, not the first), the orchestrator also prepends the preamble inline with [SYSTEM]/[USER] delimiters on the first turn — turn-2+ uses the file.
Output stream
Flat JSONL per V2packages/cli/src/run/noninteractive.ts. Text and reasoning
are already deltas and must not be deduplicated as accumulated snapshots:
providerID and modelID; those fields remain
accepted, but the V2 CLI does not promise to emit them.
Note type IS the part type at top level — NOT a nested message.part.updated envelope. step_finish (snake_case, NOT hyphen).
Troubleshooting
Bare model rejected — useprovider/model form (anthropic/claude-sonnet-4-6 not claude-sonnet-4-6).
MCP server uses literal ${VAR} token — Cursor/Claude ${VAR} syntax incompatible; ensure Crewship’s writer translated to {env:VAR}. Check by cat /output/<slug>/opencode.json.
OpenCode Go and Zen
In Credentials → Add provider, choose OpenCode Go or OpenCode Zen, follow the console link and paste an API key. Name the account and assign it to the crew or agent that will use it. Then select the matching model provider in the agent’s model settings; the runner is OpenCode.- Go models use
opencode-go/<model>and the Go subscription endpoint. - Zen models use
opencode/<model>and the metered Zen endpoint.
OPENCODE_API_KEY for Zen (mapped to opencode in OpenCode’s auth file) and
OPENCODE_GO_API_KEY for Go (mapped to opencode-go) — upstream
environment-variable conventions these are not.
Go connects using an API key, but has subscription usage limits. Its optional
Use balance setting can consume Zen credit after those limits; manage it
in the OpenCode console. Crewship does not infer
remaining subscription quota or balance-overage charges from token counts.
Zen usage estimates use Zen’s model prices. The console is authoritative for
both products’ actual billing, limits and model access.
Model suggestions are a curated subset; use a custom native model ID for
other models your OpenCode version supports. Transport verified with OpenCode
1.18.31; update older crew installations if the provider or model is unknown.
See the official Go and
Zen documentation.
Z.AI GLM Coding Plan
In Credentials → Add provider, choose Z.AI Coding Plan, subscribe to the GLM Coding Plan at Z.AI, create an API key and paste it below. Name the account and assign it to the crew or agent that will use it. The runner is OpenCode and models use thezai-coding-plan/ prefix (for example zai-coding-plan/glm-5.3).
This is a subscription product, not metered Z.AI API credit: a different
endpoint (api.z.ai/api/coding/paas/v4), a different key and its own usage
limits. The two are separate accounts in Crewship even if the same vendor
issued both keys, and one is never used as a fallback payer for the other. A
metered Z.AI key stored under Z.AI does not authenticate Coding Plan
models — the run fails closed instead of switching products.
The selected key stays in the sidecar; OpenCode receives dummy auth and keeps
its native openai-compatible protocol. Crewship’s credential slot is
ZAI_CODING_PLAN_API_KEY, mapped to zai-coding-plan in OpenCode’s auth
file; upstream itself reads ZHIPU_API_KEY for every z.ai/zhipu product, so
that shared name is not used as an account identity here. Crewship does not
infer remaining plan quota or overage pricing from token counts; the Z.AI
console is authoritative for limits and billing.
Model suggestions are the catalog entries of the deployed OpenCode version
(verified against 1.18.31); use a custom native model ID for others your plan
supports. Zhipu/BigModel regional variants are separate products and are not
configured by this connection.
Amazon Bedrock
Choose Vault → AI providers → Add AI provider → Amazon Bedrock. Enter a Bedrock API key and an optional expiration, pick its AWS region from the list and tick the inference profiles this account may use. A profile that is not listed can be added by its ID. EU profiles only keeps the region in the EU and offers onlyeu. profiles. These settings and the key are encrypted together. Pasted keys
require manual renewal; AWS role authentication is not offered by this method.
See AWS Bedrock API keys.
Test sends a minimal, billable Converse request to each permitted model.
Saving alone does not verify access. The result distinguishes authentication,
model-access/permissions, unavailable models and quota failures. Successful
verification describes access at that moment, not a guarantee of future quota.
In Pays for, choose agents or crews and a permitted model.
Crewship atomically assigns the account, sets the OpenCode runner and stores the
full model ID, for example amazon-bedrock/eu.anthropic.claude-opus-5-5.
The devcontainer’s normal preparation installs the managed OpenCode version on
its next run. Later assignments are available in the saved account’s Pays for
tab, which can also move every agent it already pays for to another permitted
model. Crew assignment persists a rule and materializes exact bindings for current
and future members. Individual model edits override the model default; removing
a crew rule removes inherited accounts and preserves explicit individual account assignments.
The rule is a default: an agent created or moved into the crew, or already in
it when the rule is saved, inherits it only when it is already on Amazon Bedrock
or has made no other choice: no model provider, the default or OpenCode runner,
and no model or a Bedrock model.
An agent configured for another provider, runner or model keeps them,
and an agent that leaves the crew keeps its model. A Bedrock model the crew’s
account does not permit is refused when the agent is created or moved.
Unsharing a crew-scoped account from a crew removes that crew’s rule. A refused
AWS response (throttling, denied access, a server error) is not recorded as
usage; a stream that breaks after AWS accepted the call is recorded as usage of
unknown size.
In New agent → Model (and Edit agent → Model), choosing Amazon
Bedrock asks for the account first and then offers that account’s permitted
models by name. The runner is shown as OpenCode and cannot be changed; the
account, model and runner are assigned together when the agent is saved.
Pays with offers only logins of the agent’s model provider, and a Bedrock
account only for a Bedrock agent. A missing, expired, revoked or
withheld account stops the run, without trying another payer.
The real key remains in the credential-injecting sidecar. The agent gets dummy
authentication, a specific account routing identifier and the native Bedrock
provider configuration. Sidecar-off execution is refused. Images with an
/etc/opencode configuration are refused for Bedrock because managed settings
can override the runtime’s privacy-critical configuration. Project configuration
and model-catalog downloads are disabled for these runs.
Account API for model settings
- The encrypted Bedrock document may omit
expires_at(or use an empty string). This means no local expiry is recorded; it does not verify AWS validity or enable renewal. Invalid nonempty dates are refused. - Repeat
POST /api/v1/credentials/{credentialId}/bedrock-assignwith the sameagent_idsand a different allowed nativemodelto change that model in place. The account stays assigned throughout the transaction. crew_idspersist a crew account/model rule, including for an empty crew. Later API, hire, internal and manifest agent inserts inherit an exact account and OpenCode model atomically. Moving an inherited agent removes the old inheritance; explicit individual assignments are preserved.PATCH /api/v1/agents/{agentId}checks Bedrock model, provider and runner changes against the assigned account in the update transaction. A denied model leaves the whole patch unapplied. Store fullamazon-bedrock/…IDs.GET /api/v1/agents/{agentId}includescredential_readinessusing the same shape as the existing/credential-readinessendpoint.readydescribes local credential/model policy, including expiry; it is not an AWS probe.- The credential binding list exposes optional
bedrock_modelfor a crew rule andinherited_from_binding_idfor materialized members. Remove a rule throughDELETE /api/v1/credentials/bindings/{bindingId}. Revoked or expired accounts stay selected and fail readiness/run checks without an alternate payer.
EU policy scope
The EU profile restriction requires an EU region and exacteu. model IDs;
global. and bare model IDs are refused. OpenCode title/compaction configuration
uses the selected model, other providers are denied, and the sidecar independently
checks every Converse model path against the account’s permitted IDs. This is a
restriction on OpenCode model inference, not a claim of whole-workspace residency:
server-side evaluators, external tools and integrations have their own destinations.
Token usage is observed incrementally from AWS EventStream responses, with a
64 KiB frame bound, and attributed to the selected account, agent and native model
under amazon-bedrock. Crewship’s catalog prices or provider fallback are estimates;
AWS billing and quotas remain authoritative.
For the CLI, create a PROVIDER_LOGIN with provider AWS_BEDROCK using an
account JSON document through stdin or a protected file, never a secret argument:
auth_method is bedrock_api_key; api_key, region, models, expires_at
(RFC3339), and eu_only carry the same fields as the form. Then use:
AWS_BEARER_TOKEN_BEDROCK slot to an agent using the OpenCode runner and
an allowed amazon-bedrock/… model. This slot identifies the account grant; the
secret is still not exported as an agent environment variable. Workspace defaults
and account pools are not fallback payers for Bedrock.
Shared sidecar and infrastructure credentials
A Bedrock peer query reuses the crew’s running sidecar without restarting its parent. If the exact peer account is not loaded there, a sidecar-only host request checks the current run, crew, agent, explicit account, model and expiry in one database snapshot. Failure stops that request; it never selects another payer or caches a fallback key. The parent sidecar’s credentials, fingerprint and general network allowlist remain unchanged. Fresh account resolution has a five-second timeout and at most 16 concurrent admissions per sidecar; streaming responses do not retain those admission slots. Bedrock inference deliberately clears ambientAWS_* authentication variables
and other model-provider keys from the OpenCode environment. A separate
infrastructure credential with provider AWS remains eligible for an explicitly
approved Keeper execution. It is not exported into OpenCode’s ambient
environment. Standard AWS environment references in an MCP configuration are
therefore unavailable on this path; use Keeper for those infrastructure actions.
Other model accounts remain withheld from Bedrock agents, including Keeper/MCP
exports. Separate-purpose AI tool grants are not implemented by this release.
Incomplete Bedrock responses still create a cost observation. Missing usage is
marked cost_confidence=unknown and usage_status=incomplete; numeric zero
means no measured amount, not a free call. Observed partial counters are a lower
bound, tagged cost_is_lower_bound=true with estimated confidence. These rows
are not a replacement for reconciling the AWS invoice.