opencode with OpenRouter: run Kimi K2, GLM or DeepSeek as your coding agent

· 3 min read · By the Sidefleet team

opencode is an open-source coding agent CLI that works with many model providers. Point it at OpenRouter and one key reaches open models such as Kimi K2, GLM, DeepSeek and Qwen. Sidefleet runs opencode the way it runs Claude Code and Codex: per task, on your own machines, with the model picked in the composer.

Why use opencode with OpenRouter?

  • One key, many models. OpenRouter puts models from many labs behind one API, and opencode addresses them all as openrouter/<model>.
  • Pay per token. Usage is billed to your OpenRouter account rather than counted against a subscription's allowance.
  • A way past a usage limit. When a Claude Code or Codex account is limited, you can fork the task into opencode and keep going.
  • Local models too. Ollama and LM Studio models run through opencode once you add them as an opencode provider.

How do you set up opencode with OpenRouter?

Install opencode on each machine that should run it, following opencode's own docs. Then give it an OpenRouter key in one of two ways. Sign in through opencode and choose OpenRouter:

opencode auth login

Or hand the key to the Sidefleet worker alone, in ~/.sidefleet/worker.env:

OPENROUTER_API_KEY=<your OpenRouter key>

The worker reads that file when it starts, so restart it after editing:

# macOS
launchctl kickstart -k gui/$(id -u)/io.sidefleet.worker

# Linux
systemctl --user restart sidefleet-worker

Check the result with sidefleet detect. It lists opencode with its version and the models it can use. The Machines page shows the same, and a task for a provider that isn't signed in fails with a message that says so, such as "OPENROUTER_API_KEY is not set".

How do you choose a model for a task?

opencode names models provider/model. Through OpenRouter that is openrouter/ followed by OpenRouter's own model ID, for example openrouter/moonshotai/kimi-k2.

The worker runs opencode models on each machine and reports what it finds, up to 400 per machine, since OpenRouter alone lists hundreds. In the composer, pick opencode as the agent and search that list. Type kimi, glm or qwen and choose the exact ID. Leave the model empty to use the machine's opencode default.

From a chat app, the start_task tool takes the same agent and model fields. See driving agents from chat apps over MCP.

How does opencode compare with Claude Code and Codex in Sidefleet?

What changes with the agent you pick for a task.
Claude CodeCodexopencode
Sign-inThe machine's Claude loginChatGPT sign-in or an API keyEach provider's key or login
Billed toThat account's planThat account's plan or keyThe provider, per token
"Ask me" approvals on the pageYesNot yetNot yet
Policy checksBefore each commandPer taskPer task
Read & edit files modeEdits allowed, other commands refusedSandboxed commands, no networkShell denied

What can opencode do in each permission mode?

  • Read & edit files: opencode edits files but can't run shell commands, so it can't run your tests.
  • Full access: every permission is granted. Use it for tasks that need to build and test.
  • Read only: opencode's plan agent, with edits, shell and fetches denied. Good for questions about the code.

Only Claude Code can relay its permission prompts to the page. For opencode, anything the mode doesn't allow is denied rather than asked. Sidefleet's policies govern opencode per task. A suspended agent gets no new tasks, and its running ones stop. The details are in running agents unattended, safely.

Can you use local models through Ollama or LM Studio?

Yes, through opencode. Add Ollama or LM Studio as a provider in opencode's config on that machine, and its models appear in the list like any other. They run on that machine's hardware, so pin those tasks to the machine that has the model.

What should you know before relying on it?

  • Sidefleet maps opencode's output from opencode's source at version 1.19, and that mapping hasn't yet been checked against many live runs. Report anything that looks wrong.
  • The cost Sidefleet shows for an opencode task is what opencode reports for each step.
  • A thread keeps the agent it started with. To move a Claude Code thread to opencode, fork it from a message.

Questions

Do I pay Sidefleet for model usage?

No. opencode calls the provider with your key, and the provider bills you. The key stays on the machine. The worker doesn't send it to the control plane, and anything that looks like a credential in the agent's narration is redacted.

Can different machines use different providers?

Yes. Each machine reports the models its own opencode can reach, and a task goes to a machine that has its agent.

Is opencode open source?

Yes. So is the Sidefleet worker that runs it, under the MIT license.

Put your machines to work

Sign in with GitHub and connect a machine. Free for 2 machines, and the agents and your repos stay on your machines.