Skip to content

OpenCode

OpenCode registers providers through opencode.json using the AI SDK. Routeplane supports two paths: an ephemeral spawn workflow that leaves OpenCode configuration untouched, and a generated provider fragment for a persistent configuration.

  • Routeplane running locally at http://127.0.0.1:4356 (Quick Start).

  • OpenCode installed:

    Terminal window
    curl -fsSL https://opencode.ai/install | bash
    # or: npm install -g opencode-ai

Use spawn for a one-off OpenCode session. It is the preferred workflow: Routeplane injects an in-memory provider only for the child process and does not edit OpenCode configuration files.

Terminal window
routeplane spawn -a opencode -m openai/gpt-5.4 --
# or non-interactive:
routeplane spawn -a opencode -m openai/gpt-5.4 -- run "say hi"

The installed OpenCode harness reference documents the injected provider and model-selector details.

For a persistent provider, generate the fragment from the running daemon:

Terminal window
routeplane integrations opencode > /tmp/routeplane-opencode-provider.jsonc

Routeplane writes only the fragment to standard output; the shell redirect creates the file. The output is one "routeplane" provider member, not a complete OpenCode file. Review it, then paste it under the top-level provider object in your OpenCode configuration. The inventory comes only from the live daemon: the command fails rather than falling back to config when the daemon is unreachable or too old to provide presets.

The secret-free fragment contains the loopback /v1 base URL, the literal {env:ROUTEPLANE_API_KEY} reference, the daemon’s live models and presets, mechanical labels, and options.reasoningEffort: "none" on each model or preset. It does not resolve or print the environment variable’s value.

Set ROUTEPLANE_API_KEY in the environment that launches OpenCode. With a local daemon configured as skip_auth: true, ROUTEPLANE_API_KEY=routeplane-local is a non-secret placeholder. With inbound authentication enabled, set it to the daemon’s real inbound Routeplane key; do not put that key in the OpenCode file.

Each key under models is an exact live daemon model id or @preset id emitted by the generator. Select one in the TUI, or prefix the exact key with the OpenCode provider id: opencode run --model routeplane/openai/gpt-5.4 or opencode run --model routeplane/@careful. See Models.