Skip to content

DeepSeek + OpenCode: Cheaper Coding Agent Setup

Set up OpenCode with DeepSeek for a cheap, open-source coding agent. The opencode.json provider block, model IDs, API key, pricing, and fixes — on Windows or WSL.

MGMCSA Guru Team June 19, 2026 3 min read
OpenCode configured with a DeepSeek provider on Windows

OpenCode is a free, open-source coding agent; DeepSeek is among the cheapest capable models. Put them together and you’ve got a terminal agent that reads your repo, edits files, and runs commands for cents per session — no subscription on either side. It’s one of the best value combinations going in 2026.

This is the exact setup: the provider config, model IDs, and the small things that go wrong. For OpenCode’s general provider model, see OpenCode custom providers.

Step 1: Install OpenCode and get a key

npm install -g opencode-ai

Create a DeepSeek account, add a little credit, and generate an API key. On Windows, WSL gives the cleaner shell — see install OpenCode on Windows with WSL and the WSL install guide.

Step 2: Add the DeepSeek provider

OpenCode connects to OpenAI-compatible APIs through the @ai-sdk/openai-compatible adapter. Add this to opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "deepseek": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "DeepSeek",
      "options": {
        "baseURL": "https://api.deepseek.com/v1",
        "apiKey": "{env:DEEPSEEK_API_KEY}"
      },
      "models": {
        "deepseek-chat": { "name": "DeepSeek Chat" },
        "deepseek-reasoner": { "name": "DeepSeek Reasoner" }
      }
    }
  },
  "model": "deepseek/deepseek-chat"
}

Export the key:

export DEEPSEEK_API_KEY="sk-your-key"

Step 3: Run it

opencode

The default model is deepseek/deepseek-chat from the config. Switch in the TUI or change the model key.

DeepSeek models in OpenCode

deepseek/deepseek-chat General coding; fastest, cheapest
deepseek/deepseek-reasoner Thinking mode for harder tasks

Pricing

DeepSeek is pay-per-token only — no coding plan — with cache-hit discounts and off-peak windows that drop the rate at set hours. Paired with free OpenCode, the only cost is DeepSeek’s tokens, which are among the lowest available. Rates change with promotions and versions, so confirm on the official pricing page. Detail: DeepSeek V4 pricing explained.

Troubleshooting

  • Provider not found — the provider key (deepseek) must match the model prefix (deepseek/...).
  • Auth errorsDEEPSEEK_API_KEY isn’t set in the shell that launched OpenCode.
  • Format errors — you’re on /anthropic; switch to /v1.
  • Model rejected — confirm the current model IDs in DeepSeek’s docs.

DeepSeek + OpenCode checklist

  • OpenCode installed (npm i -g opencode-ai)
  • DeepSeek key created and exported
  • Provider block with @ai-sdk/openai-compatible and /v1 baseURL
  • deepseek-chat / deepseek-reasoner listed
  • Default model set; launched with opencode

Wrapping up

DeepSeek plus OpenCode is about as cheap as a real coding agent gets: a free, open tool on a pay-per-token model that costs cents. Add the provider block with the /v1 base URL and an {env:DEEPSEEK_API_KEY}, list deepseek-chat and deepseek-reasoner, set a default, and launch.

For other backends in OpenCode, see GLM + OpenCode and MiniMax M2 + OpenCode. To run DeepSeek elsewhere, see DeepSeek with Codex CLI.

Frequently asked questions

Is OpenCode with DeepSeek free?

OpenCode itself is free and open source; you pay only DeepSeek's pay-per-token rate, which is very low. There's no subscription on either side, so a few dollars of DeepSeek credit goes a long way.

What base URL does OpenCode use for DeepSeek?

The OpenAI-compatible endpoint https://api.deepseek.com/v1. OpenCode talks the OpenAI format through @ai-sdk/openai-compatible, so the /v1 URL is correct — not the Anthropic one.

Which DeepSeek models can I list?

deepseek-chat for general coding and deepseek-reasoner for thinking-heavy work. List both in the models map and pick one as your default with the model key.

Where does the config go?

In a project-level opencode.json or the global config (commonly ~/.config/opencode/opencode.json). The OPENCODE_CONFIG environment variable can override both if set.

Does this run on Windows?

Yes, and it runs cleanly in WSL. The config is identical either way; WSL just gives the smoother shell for a terminal agent.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.