OpenCode CLI
OpenCode CLI offers a single CLI with multiple provider backends.
Requirements
opencodeinstalled.Provider credentials (Anthropic/OpenAI/Google/etc).
Default model configured or explicit
--modelin command.
Setup
Install OpenCode CLI.
Set provider API keys.
Verify local command works.
Configure in AI Backend settings tab.
Example environment setup:
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
export GOOGLE_API_KEY="..."Configuration
Preferred Backend
OpenCode CLI
OpenCode CLI Command
opencode --model anthropic/claude-sonnet-4-5
Other model examples:
Notes
Model Configuration
If no default model is configured and no --model is provided, embedded runs can fail with process has not exited.
Output Parsing
The extension filters OpenCode CLI output to extract the actual AI response:
Status/metadata lines: All lines starting with
>(under 120 characters) are treated as OpenCode status output and filtered. This includes> thinking,> loading,> building, and similar status messages.Prompt echo removal: Only long prompt lines (40+ characters) are used for dedup filtering, preventing false positives where short common terms (e.g., "SQL Injection", "Analyze") would incorrectly match real response content.
Version banners: Lines starting with
opencode vorsession:are filtered.
Idle Timeout
OpenCode has two timeouts that can end a run:
Idle timeout (
OPENCODE_IDLE_TIMEOUT_MS = 30_000, 30 seconds): the process is force-killed if it produces no new stdout after initial status lines. Runs that take longer than 30 s to start producing output will look blank.Hard CLI timeout (120 seconds, shared with other CLI backends): an overall ceiling that terminates the process regardless of output activity.
Both are intentionally short to prevent runaway processes in the chat UI. For very large prompts, prefer a faster model or split the request.
Windows
npm-installed CLI shims are resolved automatically on Windows. The extension detects .cmd siblings and uses them instead of shell script shims that cannot be executed directly by Java.
Troubleshooting
command not found: use full binary/shim path.Windows: npm shim paths are resolved automatically. If auto-resolution fails, use the full
.cmdpath:C:\\Users\\<you>\\AppData\\Roaming\\npm\\opencode.cmd.Provider errors: verify the API key for selected provider.
process has not exited: configure a default model or add--model.Blank responses: check that the model is producing output by running the same command in a terminal. If the model takes longer than 30 seconds to start producing output, the process may time out.
Unrendered responses: ensure the response is not being filtered by the output parser. Check the extension output tab for raw process output.
Related Pages
Last updated
