For the complete documentation index, see llms.txt. This page is also available as Markdown.

OpenCode CLI

OpenCode CLI offers a single CLI with multiple provider backends.

Requirements

  • opencode installed.

  • Provider credentials (Anthropic/OpenAI/Google/etc).

  • Default model configured or explicit --model in command.

Setup

  1. Install OpenCode CLI.

  2. Set provider API keys.

  3. Verify local command works.

  4. 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

Setting
Value

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 v or session: 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 .cmd path: 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.

Last updated