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
providerkey (deepseek) must match themodelprefix (deepseek/...). - Auth errors —
DEEPSEEK_API_KEYisn’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.