Router Desk

HomeOpenCode and OpenRouter

OpenCode and OpenRouter

One OpenRouter key in OpenCode’s config is available to the terminal UI, the desktop app, and the IDE extension.

Updated 2026-09-27

OpenCode is an open-source agent with a terminal UI, a desktop app for macOS, Windows, and Linux, and an IDE extension. OpenRouter’s cookbook says the terminal and desktop apps share opencode.json and the same stored credentials.

Connect

  • Create a key at openrouter.ai/settings/keys.
  • Install OpenCode with the script on opencode.ai, npm i -g opencode-ai, or brew install anomalyco/tap/opencode.
  • Start it in a project and run /connect. OpenRouter is a built-in provider.
  • Set a default model in the config if you do not want to pick one every session.

Unlike Claude Code, OpenCode is meant to point at many slugs. A DeepSeek Flash default and a Sonnet 5 escalation can live in the same config. Provider routing options in the cookbook cover failover. The bill follows whichever slug the session used.

MCP is separate. Adding https://mcp.openrouter.ai/mcp lets the agent read the catalog and your balance. It does not replace the model calls OpenCode already makes.

Questions

How do I connect OpenCode to OpenRouter?

Install OpenCode, start a session, and run /connect. Choose OpenRouter and paste a key from openrouter.ai/settings/keys.

Does the desktop app need a second key?

No. OpenRouter’s cookbook says the desktop app reads the same credentials as the terminal.

Where is the official guide?

https://openrouter.ai/docs/cookbook/coding-agents/opencode-integration

  • Claude Code on OpenRouter

    Point Claude Code at https://openrouter.ai/api, put the OpenRouter key in ANTHROPIC_AUTH_TOKEN, and set ANTHROPIC_API_KEY to an empty string.

  • Coding agents

    OpenRouter’s coding-agent apps include Claude Code, OpenCode, and others. The agent is the client. The model is the slug you attach.

  • OpenRouter MCP

    The OpenRouter MCP server is https://mcp.openrouter.ai/mcp. It lets a coding agent read models, prices, and your credits after an OAuth login.

  • Coding models

    Coding-model choice on OpenRouter is price, context, and tool-call reliability. DeepSeek V4, Qwen3.7 Max, GLM 5.2, and Sonnet 5 are the slugs to price first.

Sources