Connect OpenCode to the DeepSeek API

OpenCode is an open-source coding agent for the terminal, desktop, and web. It has a built-in DeepSeek provider, so the latest OpenCode release can call DeepSeek directly without a Responses API bridge.

What you need

  • OpenCode v1.14.24 or newer.
  • A DeepSeek-compatible API key.
  • deepseek-v4-flash for fast everyday coding or deepseek-v4-pro for difficult repository-wide work.

1. Install or update OpenCode

Install the latest release from the OpenCode download page, then confirm the installed version:

opencode --version

Upgrade before troubleshooting provider errors. Older OpenCode builds may not recognize current DeepSeek V4 model IDs or reasoning fields.

2. Connect OpenCode to DeepSeek

  1. Run opencode in your project directory.
  2. Type /connect.
  3. Search for deepseek and select the built-in DeepSeek provider.
  4. Paste your DeepSeek-compatible API key.
  5. Select deepseek-v4-flash or deepseek-v4-pro.

OpenCode stores provider credentials locally. Do not paste an API key into a repository file or commit it to Git.

3. Pick the right DeepSeek V4 model

ModelBest forTrade-off
deepseek-v4-flashQuick fixes, code search, explanations, repetitive editsLower cost and latency; lower reasoning ceiling
deepseek-v4-proCross-file refactors, debugging, architecture, long agent runsStronger reasoning; slower and more expensive

Start with Flash. Move to Pro when the task needs deeper planning or Flash repeatedly fails the same constraint.

4. Use a custom DeepSeek-compatible API endpoint

If your API provider uses the OpenAI Chat Completions format, add it as a custom OpenAI-compatible provider in OpenCode. The required values are:

API type: OpenAI-compatible / Chat Completions
Base URL: https://your-api.example/v1
API key: your provider key
Model: deepseek-v4-flash or deepseek-v4-pro

The base URL must expose /chat/completions. OpenCode does not need OpenAI Responses for this setup.

5. Verify the connection

Open a small repository and run a bounded task:

Read package.json, identify the test command, and explain what you would run.
Do not edit files yet.

A successful response confirms authentication, model routing, and basic tool access. Then test one edit and one terminal command before starting a long agent run.

OpenCode DeepSeek troubleshooting

Provider or model not found

Upgrade OpenCode, reconnect the provider, and use the exact current model ID. Avoid legacy aliases when the provider lists V4 models explicitly.

401 authentication error

Recreate the API key, remove accidental spaces, and confirm that the key belongs to the same service as the configured base URL.

404 endpoint error

Check whether your provider expects a base URL ending in /v1. The final request must reach /chat/completions; do not point this OpenCode setup at /v1/responses.

Reasoning or tool calls fail after the first turn

Update OpenCode first. DeepSeek thinking models may require reasoning state to be replayed between turns, and older provider integrations can drop that field. If the built-in provider still fails, test Flash in non-thinking mode to isolate the problem.

OpenCode DeepSeek FAQ

Does OpenCode support DeepSeek?

Yes. Current OpenCode releases include a DeepSeek provider. Use /connect, select DeepSeek, paste an API key, and choose a current V4 model.

Which DeepSeek model should I use in OpenCode?

Use DeepSeek V4 Flash for high-volume coding and fast edits. Use DeepSeek V4 Pro for complex debugging, cross-file refactors, and long-running agent tasks.

Does OpenCode need the OpenAI Responses API for DeepSeek?

No. OpenCode can use DeepSeek through its built-in provider or an OpenAI-compatible Chat Completions endpoint. Responses-only clients such as Codex need a protocol bridge; OpenCode normally does not.

Can I use my own DeepSeek-compatible API with OpenCode?

Yes. Add it as a custom OpenAI-compatible provider, set its base URL and key, and map the available DeepSeek model ID. Verify that the endpoint implements Chat Completions and tool calling.