Installing OpenCode and connecting DeepSeek

Written by

in

OpenCode is an open programming agent that lives right in the terminal. It can read project files, edit code, run commands and tests, search the repository and work with git – about the same thing that Claude Code and other console agents do. The main difference is that OpenCode is not tied to one model provider: dozens of providers can be connected through it, including DeepSeek. In this post I will describe installing the agent and connecting DeepSeek to it.

What you need

You only need two things to work:

  • Modern terminal. WezTerm, Alacritty, Ghostty, Kitty or any other will do.
  • API key of the provider. In our case, DeepSeek.

Node.js is not required if you install the agent with a standard installation script – the binary arrives ready-made.

Installation

The easiest way is the official installation script:

curl -fsSL https://opencode.ai/install | bash

It will detect the platform itself and put the executable file in PATH. After installation, you should check that everything is in place:

opencode --version

If the command displays the version, the installation was successful.

Installation using other methods

If you prefer package managers, there are several options. Via Node.js:

npm install -g opencode-ai

Bun, pnpm and Yarn can do the same:

bun install -g opencode-ai
pnpm install -g opencode-ai
yarn global add opencode-ai

macOS and Linux have Homebrew. Please note: it is tap from the developers that is recommended, and not the official formula – it is updated less frequently:

brew install anomalyco/tap/opencode

On Arch Linux:

sudo pacman -S opencode
paru -S opencode-bin

The first command installs the stable version from the repository, the second – the latest one from the AUR.

Installation on Windows

In Windows, it is recommended to work via WSL: this way the performance is higher and the compatibility with the agent’s capabilities is complete. But there are also native methods. Via Chocolatey, Scoop or npm:

choco install opencode
scoop install opencode
npm install -g opencode-ai

There is also an option through Mise, as well as a Docker container:

mise use -g github:anomalyco/opencode
docker run -it --rm ghcr.io/anomalyco/opencode

Finally, the finished binary can always be taken from the releases page on GitHub.

DeepSeek key

The key is created in your DeepSeek personal account. Go to platform.deepseek.com, open the section with API keys and click create a new key. It is better to save the resulting string immediately: it will be shown only once.

DeepSeek connection

Then everything is done inside the agent itself. Launch OpenCode in the terminal:

opencode

In the interface we execute the connection command:

/connect

In the list of providers that opens, look for DeepSeek, select it and insert the API key. Keys added in this way are saved to a file:

~/.local/share/opencode/auth.json

After connecting, all that remains is to select the model with the command:

/models

DeepSeek models will be available in the list, including deepseek-v4-pro, deepseek-flash and deepseek-v4-flash. For routine work in the repository, the flash option is sufficient; For complex tasks, it makes sense to switch to pro.

Configuration via config

If you don’t want to store the key through a master or need to set your own API address, the provider is described directly in the opencode.json configuration file:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "deepseek": {
      "options": {
        "baseURL": "https://api.deepseek.com"
      }
    }
  }
}

The baseURL field is useful if you go through a proxy or your own gateway. In this case, it is convenient to transfer the key itself to an environment variable:

export DEEPSEEK_API_KEY=ваш_ключ_deepseek
opencode

This option is good for CI and one-time launches: the key does not end up in storage, but lives only in the environment of the process.

First launch in the project

Go to the project directory and launch the agent:

cd ваш_проект
opencode

The first step is to initialize it:

/init

OpenCode will analyze the project structure and create a file AGENTS.md – an analogue of instructions for the agent. This file is worth committing to git: it helps the agent understand the conventions and patterns adopted in the project.

How to use it

The work is structured in much the same way as with other agents. A couple of tricks you should know right away:

  • Planning mode. The Tab key switches the agent between planning and assembly modes. In the first, he only suggests how to solve the problem and does not change anything – it is convenient to check the idea before making changes.
  • Links to files. The @ key opens a fuzzy search through project files to transfer a specific file to the agent in the context.
  • Rolling back changes. The /undo command undoes the last edits and returns the original request, /redo returns them back. You can roll back several steps in a row.
  • Sharing a conversation. The /share command creates a link to the current conversation and copies it to the clipboard. By default, conversations are not published anywhere.

For simple changes, you don’t have to switch to planning mode, but immediately describe what needs to be done and specify the files via @.

What to pay attention to

A couple of practical points. OpenCode does not require a subscription: you pay the provider directly when you spend tokens, so long sessions with DeepSeek are predictably cheaper than top models. The key is stored locally in auth.json – this is worth considering on a shared machine, but for other people’s environments an environment variable is more reliable.

And one more thing: the quality of answers to complex architectural problems differs among models of different classes, so for design it makes sense to take a stronger model, and give the routine away to a quick and cheap one.

Links

https://opencode.ai/
https://opencode.ai/docs/
https://opencode.ai/docs/providers/
https://github.com/anomalyco/opencode
https://platform.deepseek.com/api_keys
https://api-docs.deepseek.com

Sources

https://opencode.ai/docs/
https://opencode.ai/docs/providers/#deepseek
https://github.com/anomalyco/opencode/releases
https://models.dev/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *