OpenCode is an open-source AI coding agent available as a terminal interface and desktop app (beta). It features LSP integration, multi-session support, sharable session links, and compatibility with 75+ LLM providers — including OpenRouter for unified multi-model access through a single API key.
For additional installation methods (Bun, pnpm, Yarn, Arch Linux, Windows), see the OpenCode installation docs.
sk-or-...)OpenCode supports OpenRouter as a built-in provider. Use the interactive /connect command:
Start OpenCode in your project directory:
Run the /connect command and select OpenRouter:
Paste your OpenRouter API key when prompted.
Run /models to select a model:
Your requests will now be routed through OpenRouter.
You can also configure OpenRouter directly in your opencode.json config file:
Set your API key via the /connect command or by adding it to ~/.local/share/opencode/auth.json:
When using OpenRouter, you can control which upstream providers handle your requests by adding options.provider to individual models in your config:
For a full breakdown of routing options, see the Provider Routing docs.
Switch between any model available on OpenRouter — Anthropic, OpenAI, Google, xAI, Meta, DeepSeek, and many more — without managing separate API keys for each provider.
If one provider is unavailable or rate-limited, OpenRouter automatically routes to another, keeping your coding sessions uninterrupted.
For teams, OpenRouter provides centralized budget management. Set spending limits, allocate credits, and monitor usage across developers using OpenCode from your OpenRouter Activity Dashboard.
Switch models by updating your config or using the /models command — no need to reconfigure API keys or endpoints.
/connect. Check at openrouter.ai/keys.~anthropic/claude-sonnet-latest).