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 (default), or add an explicit --model override
Explicit model examples:
Notes
Model Configuration
The default extension command is opencode, so configure a default model in OpenCode or add --model to the command. If neither is set, 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
Related Pages
Last updated
