---
title: "How to Use DeepSeek with OpenClaw and OpenCode (2026)"
description: "Wire DeepSeek V4 Pro into OpenClaw or OpenCode. Copy-paste provider config for both agents, which DeepSeek model to pick, and how to dodge the API reliability issues."
date: 2026-06-02
location: San Francisco, CA – Jun 2nd, 2026
image: /images/deepseek-openclaw-setup-hero.jpg
keywords: "deepseek openclaw, deepseek opencode, opencode deepseek, deepseek for openclaw, deepseek v4 pro, deepseek coding agent setup"
faq:
  - question: "How do I add DeepSeek to OpenClaw?"
    answer: "Add DeepSeek as a provider in ~/.openclaw/openclaw.json under models.providers with baseUrl 'https://api.deepseek.com/v1', your DeepSeek API key, and api 'openai-completions'. Add your model (e.g. deepseek-v4-pro) to the agents.defaults.models allowlist, then run 'openclaw gateway config.apply'. Both the provider definition and the allowlist entry are required."
  - question: "How do I add DeepSeek to OpenCode?"
    answer: "Run 'opencode auth login', choose Other, enter a provider ID like 'deepseek' and your API key. Then add a matching provider block in opencode.json with npm '@ai-sdk/openai-compatible' and baseURL 'https://api.deepseek.com/v1', list your models, restart OpenCode, and pick the model from /models."
  - question: "Which DeepSeek model is best for coding agents?"
    answer: "DeepSeek V4 Pro is the strongest pick — it scores 80.6% on SWE-bench Verified with a 1M-token context window, and it's among the cheapest frontier-class coding models available. V4 Flash is cheaper still and lands close behind. Older V3.2 remains a budget option but is well behind V4 on coding."
---

DeepSeek has quietly become the price-performance story in coding models. [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), released in April 2026, hits 80.6% on SWE-bench Verified, frontier-class scores at a fraction of what Claude or GPT charge per token. If you drive [OpenClaw](/blog/best-models-for-openclaw) or OpenCode, it's one of the best value models you can point them at.

Both agents speak the OpenAI-compatible API format, so wiring DeepSeek in takes a small config block. Here's how to do it in each, which model to choose, and the one reliability gotcha to plan around.

## Which DeepSeek model to use

| Model | SWE-bench Verified | Context | Best for |
|---|---|---|---|
| **DeepSeek V4 Pro** | 80.6% | 1M | Default — frontier coding, cheap |
| **DeepSeek V4 Flash** | ~79% | 1M | High volume, even cheaper |
| **DeepSeek V3.2** | older gen | 164K | Legacy budget option |

Start with **V4 Pro**. It's a Mixture-of-Experts model (1.6T total parameters, ~49B active) with a 1M-token context window, and DeepSeek made a 75% price cut permanent in May 2026. So you get frontier coding scores at sub-dollar pricing. Drop to **V4 Flash** if you're running heavy volume and want to shave cost further for a small quality trade. There's a fuller breakdown in [best DeepSeek models for OpenClaw](/blog/best-deepseek-models-for-openclaw).

## Setup in OpenClaw

OpenClaw config lives at `~/.openclaw/openclaw.json`. Two things are required: the provider definition and the model allowlist. Forgetting the allowlist is the most common reason a model "doesn't show up."

Add DeepSeek under `models.providers`:

```json5
{
  "models": {
    "providers": {
      "deepseek": {
        "baseUrl": "https://api.deepseek.com/v1",
        "apiKey": "your-deepseek-api-key",
        "api": "openai-completions",
        "models": [
          {
            "id": "deepseek-v4-pro",
            "name": "DeepSeek V4 Pro",
            "reasoning": true,
            "contextWindow": 1000000,
            "maxTokens": 65536
          }
        ]
      }
    }
  }
}
```

Then allow the model under `agents.defaults.models` using the fully-qualified `provider/model` name:

```json5
{
  "agents": {
    "defaults": {
      "models": ["deepseek/deepseek-v4-pro"]
    }
  }
}
```

Apply it:

```bash
openclaw gateway config.apply --file ~/.openclaw/openclaw.json
```

Run `/models` to confirm it registered, then `/model deepseek/deepseek-v4-pro` to switch to it. Full provider walkthrough: [OpenClaw custom provider setup](/blog/openclaw-custom-provider-setup).

## Setup in OpenCode

OpenCode keeps credentials and provider config separate. First store the credential:

```bash
opencode auth login
```

Choose **Other**, enter a provider ID (use `deepseek`), and paste your DeepSeek API key. The credential lands in `~/.local/share/opencode/auth.json`.

Then add a matching provider block in `opencode.json` (the provider ID must match what you used during auth):

```json
{
  "provider": {
    "deepseek": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.deepseek.com/v1"
      },
      "models": {
        "deepseek-v4-pro": { "name": "DeepSeek V4 Pro" }
      }
    }
  }
}
```

Restart OpenCode and pick the model from `/models`. If it doesn't appear, the usual culprits are a provider-ID mismatch between the credential and the config, invalid JSON, or a model ID that doesn't match DeepSeek's API. More detail: [OpenCode custom provider setup](/blog/opencode-custom-provider-setup).

## The easiest path: one endpoint for both

DeepSeek's own API is cheap but not always reliable: it returns 503s during peak hours, and time-to-first-token can lag. If you'd rather not build retry logic or juggle a separate DeepSeek account, route through a gateway instead:

- **[haimaker.ai](https://haimaker.ai)** — point either agent at one OpenAI-compatible endpoint (`https://api.haimaker.ai/v1`) and get DeepSeek V4 Pro alongside hundreds of other models, with unified billing and the ability to fall back to another model when DeepSeek is busy. Same config blocks as above; just swap the `baseUrl` / `baseURL` and use your haimaker key. On OpenClaw, `npx -y @haimaker/connect --openclaw` generates that provider block pointed at the Haimaker endpoint, so there's nothing to paste — [connect setup](/connect) has the details.
- **DeepSeek directly** — lowest nominal price if you only ever use DeepSeek and don't mind handling the occasional retry. Set a generous request timeout (60s+).

<a href="https://haimaker.ai?utm_source=openclaw_blog&utm_medium=cta&utm_campaign=deepseek-setup" class="cta-button">GET A DEEPSEEK ENDPOINT</a>

## The bottom line

DeepSeek V4 Pro is the cheap-frontier sweet spot for coding agents in 2026, and it drops into both OpenClaw and OpenCode with a short OpenAI-compatible provider block. Use it directly if you want the rock-bottom token price and can tolerate the occasional 503, or route it through a gateway if you'd rather have failover and one bill for every model.
