In short.
This guide teaches developers to use OpenCode, an open-source AI coding agent, with OpenRouter, which provides access to many AI models through one API key. It explains terminal and desktop connection methods, shared configuration and credentials, default models, additional model entries and upstream provider preferences. It provides no prices or measured coding results. Latest-model aliases can change their target over time; pinned slugs select named model versions. Installation success, model availability, failover reliability and privacy behavior remain untested.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete selected page at [https://openrouter.ai/docs/cookbook/coding-agents/opencode-integration.md], including installation instructions, configuration examples, latest-alias notes, routing, troubleshooting and the privacy notice. Linked documentation, the documentation index, installer contents, downloads, repository files, model catalog and privacy policy are excluded. Installation, authentication, shared configuration, model requests, provider failover, spending controls and privacy behavior remain untested. No commands or model calls were executed, and no measured performance or cost results are available.
The overview
identity
The resource is OpenRouter's OpenCode integration guide at [https://openrouter.ai/docs/cookbook/coding-agents/opencode-integration.md]. It teaches how to connect OpenCode's built-in OpenRouter provider. OpenCode is described as an open-source AI coding agent with terminal, desktop and IDE interfaces; the detailed connection instructions cover terminal and desktop.
assessment
The guide provides enough configuration detail to follow a connection attempt: installation options, credential entry, model selection, configuration paths and common error remedies. Its strongest practical feature is explaining how terminal and desktop share the same provider setup. It does not establish installation success on a particular machine, coding accuracy, latency or service reliability.
users
The guide suits developers who want OpenRouter model access inside OpenCode, including people moving between terminal and desktop. Beginners can use the desktop settings or interactive terminal commands. Experienced developers get JSON configuration, provider-prefixed model identifiers and routing options. Familiarity with project folders and API keys is assumed; coding-agent fundamentals are not taught.
capabilities
The documented integration supports choosing OpenRouter models, adding models missing from the picker, setting a default model and overriding it for an individual invocation. It also exposes upstream provider preferences and fallback settings. The page describes shared terminal and desktop credentials, automatic provider failover and team spending controls.
OpenCode features such as language-server integration, multiple sessions and shareable session links are mentioned as background. Their behavior and interaction with OpenRouter are not demonstrated.
Using it
requirements
You need an OpenRouter account and API key, an installed OpenCode interface and a project folder. This hosted model route requires network access. Terminal installation options include a shell installer, npm and Homebrew. Desktop downloads are listed for macOS, Windows x64 and Linux .deb or .rpm packages. Minimum operating-system versions, memory requirements and installation-tool versions are unspecified.
mechanism
OpenCode sends model requests through its OpenRouter provider using an OpenRouter API key. OpenRouter then routes requests to upstream model providers. A top-level model setting uses provider_id/model_id, so an OpenRouter identifier starts with openrouter/. Entries under provider.openrouter.models use the OpenRouter model slug without that prefix.
Per-model options.provider settings control upstream provider preferences. The example uses order: ["anthropic"] and allow_fallbacks: true. These settings concern which provider serves requests; model selection is configured separately.
setup
For terminal use, install OpenCode, start opencode in the project directory, enter /connect, choose OpenRouter and supply the API key. Then use /models to select a model. For desktop use, open a project, find OpenRouter under Settings and Providers, connect with an API key and choose a model in the session view.
Project settings belong in opencode.json at the project root; user-wide settings belong in ~/.config/opencode/opencode.json. Both accept JSONC. Credentials are stored in ~/.local/share/opencode/auth.json, with XDG_DATA_HOME changing the base location. Terminal and desktop share credentials. The page advises fully restarting OpenCode if a newly connected provider's models do not appear.
example
Combining the page's openrouter/ prefix rule with the pinned slug it names gives {"model":"openrouter/anthropic/claude-sonnet-4.5"}; the page itself shows only the latest-alias form {"model":"openrouter/~anthropic/claude-sonnet-latest"}. The leading ~ is part of the alias and must be preserved.
The page says the default applies to terminal, desktop and opencode run, with --model or -m available for invocation-specific overrides. These are configuration examples; no executed coding task or resulting output is provided.
Assessment & evidence
limitations
Automatic failover is described as maintaining sessions when providers are unavailable or rate-limited, but the page supplies no availability measurements or evidence that another provider will always be usable. Model-picker entries can require a restart or manual configuration. IDE support is mentioned without corresponding connection steps.
The privacy note says OpenRouter does not log source-code prompts unless prompt logging is enabled. It does not establish upstream provider logging, request-metadata retention or OpenCode telemetry behavior. The linked privacy policy and the contents of installation scripts are outside the selected page.
reasoning
The documented shared credentials and model-switching controls support using this guide when you want several hosted model options across terminal and desktop. That fit follows from the configuration described; productivity gains are not measured. A pinned model slug offers more control over model identity than a latest alias because the latter deliberately changes its target.
alternatives
The page says OpenCode supports more than 75 LLM providers, so other provider integrations are possible alternatives to the OpenRouter route. Their setup, prices and tradeoffs are not explained. Within the documented integration, terminal and desktop offer alternative interfaces using shared credentials. No competing coding agent is compared on coding quality, privacy, latency or cost.
evidence
The sole source is the complete OpenRouter page titled OpenCode at [https://openrouter.ai/docs/cookbook/coding-agents/opencode-integration.md], captured as selected-page.txt on 2026-11-14T22:39:24.730Z. Its source revision is sha256:603826d317a0d5e9c76cbd0aac4f94224bd75d14e1678351925d9498a3600c48.
The page contains instructions, configuration examples and provider claims. It contains no execution logs, coding benchmarks, price table or independent comparison.
Access & freshness
costs
The page describes centralized spending limits, credit allocation and usage monitoring for teams. It supplies no model rates, subscription prices, minimum credit requirements or worked session-cost example. The total cost of using OpenCode through OpenRouter is unknown from this page. Calling OpenCode open source does not establish that hosted model usage is free.
rights
The page calls OpenCode open source and links to [https://github.com/anomalyco/opencode], but reproduces no software license terms. It also provides no documentation redistribution license or model-output rights terms. The applicable permissions and obligations cannot be established from the selected page alone.
freshness
The capture is dated 14 November 2026, but the page gives no publication date, update date or applicable OpenCode release. Current model availability, interface labels and installation-package availability are unknown. Latest aliases explicitly change their target models, so the example configuration does not fix which model a future request will use.
actions
Before adopting the setup, confirm the intended model's exact slug and availability at [https://openrouter.ai/models], and check its current price with OpenRouter, because this page gives no prices. Review data-handling terms for OpenRouter and the chosen upstream provider. The page points to [https://openrouter.ai/privacy] for OpenRouter's policy. Choose deliberately between a pinned model and an updating alias.
Follow the connection steps for your interface, confirm stored authentication with opencode auth list and restart if models are missing. Assess a small representative coding task and its actual usage charges before relying on the integration for regular project work.
