To set up a DeepSeek coding agent, top up a balance on the DeepSeek platform, create an API key and give it to your agent. DeepSeek makes its own open-source agent, DeepSeek Harness. OpenCode has DeepSeek built in, and DeepSeek publishes setups for Codex CLI and Claude Code through its OpenAI Responses and Anthropic-compatible endpoints. Contenox takes the key too. DeepSeek bills per token from your prepaid balance.
Use DeepSeek with your agent
| Agent | Supported? | How | Note |
|---|---|---|---|
| DeepSeek Harness | Yes, DeepSeek’s own | npx @deepseek-ai/dsh web, then Settings → Models | Open source (MIT), in developer preview. Runs in your browser |
| Claude Code | Works, not supported by Anthropic | Environment variables pointing ANTHROPIC_BASE_URL at https://api.deepseek.com/anthropic | DeepSeek documents it. Anthropic doesn’t support routing Claude Code to non-Claude models. |
| Codex CLI | Yes, by DeepSeek’s docs | [model_providers.deepseek] in ~/.codex/config.toml | DeepSeek added a Responses API for Codex. |
| OpenCode | Yes | /connect → DeepSeek → paste the key | Built in. DeepSeek recommends v1.18.30 or later. |
| Contenox | Yes | Backends → Providers → DeepSeek |
DeepSeek Harness
DeepSeek Harness (dsh) is DeepSeek’s own agent: it reads and edits files in a workspace, runs commands, keeps a plan, and asks before operations its permission policy gates. Everything in it is a plugin, including the tools. It is open source under the MIT license, and in developer preview: the project warns there will be breaking changes, and asks you to read its safety notice before running it.
With Node.js installed:
npx @deepseek-ai/dsh web
That starts a web interface at http://127.0.0.1:3080 and opens it in your browser. Enter your DeepSeek API key under Settings → Models, choose a workspace, and start a session. The workspace defaults to the folder you started dsh in.
DeepSeek also documents setups for OpenClaw, Hermes, Reasonix, WorkBuddy/CodeBuddy and Qoder in its agent integrations docs.
What you need
- An account on the DeepSeek platform with a balance. Requests fail with a 402 error when the balance is empty.
- An API key from the same platform.
OpenCode
Start opencode in your project, type /connect, search for DeepSeek and paste the
key. Pick a DeepSeek model with /models. The key is saved in
~/.local/share/opencode/auth.json.
Codex CLI
DeepSeek ships a setup script that writes ~/.codex/config.toml and a model list, and
backs up your old config. Windows PowerShell:
irm https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.ps1 | iex
macOS or Linux:
bash <(curl -fsSL https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh)
The core of the config it writes:
model = "deepseek-flash"
model_provider = "deepseek"
[model_providers.deepseek]
name = "deepseek"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
experimental_bearer_token = "<your DeepSeek API Key>"
The full file, with the model catalog, is on DeepSeek’s Codex page.
The plain-text trap: this puts your key in config.toml as plain text. Don’t commit
or share that file.
The vanishing-sessions gotcha: sessions you start with DeepSeek are hidden when you switch back to a ChatGPT sign-in, and the other way round. Nothing is deleted.
Claude Code
DeepSeek’s Anthropic-compatible endpoint lets Claude Code run on DeepSeek models. Anthropic
doesn’t support this setup; DeepSeek documents it. Set the variables in the terminal before you start
claude. Windows PowerShell:
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="<your DeepSeek API Key>"
$env:ANTHROPIC_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-flash"
claude
macOS or Linux:
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your DeepSeek API Key>
export ANTHROPIC_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-flash
claude
The [1m] is part of the model name. DeepSeek’s
Claude Code page
lists a few more optional variables.
The Opus-name trap: any model name starting with claude-opus is served by
deepseek-v4-pro and billed at that rate; claude-sonnet and claude-haiku names go to
deepseek-flash. The variables above send every request to Flash.
Which DeepSeek model should I pick?
DeepSeek currently offers two models through its API, both with a 1M-token context window:
deepseek-v4-pro: the larger model. Use it for changes across many files and for planning.deepseek-flash: faster and cheaper. Good for small edits, questions and routine work.
Both think before they answer by default; turn reasoning down for small edits, since it
costs tokens and time. The older deepseek-v4-flash name is still accepted and is served
by the current Flash model, as DeepSeek’s
models and pricing page explains.
How billing works
You pay per token, for input and output. DeepSeek uses any granted balance before your topped-up balance. Rates differ between peak and off-peak hours, so the same session can cost less at a different time of day. Agent sessions resend context often, so cost depends on how long a session runs and how much of the project the agent reads. Current rates and hours are on the pricing page.
Common errors
- 401 “Authentication Fails”: the key is wrong or was deleted. Create a new one.
- 402 “Insufficient Balance”: top up your balance on the platform.
- 429 “Rate Limit Reached”: too many requests at once. Wait and try again.
- 503 “Server Overloaded”: heavy traffic at DeepSeek. Try again shortly, or switch to another provider.
Where does my code go?
DeepSeek’s privacy policy says it collects, processes and stores personal data in the People’s Republic of China. If your employer or client has rules about where code may be sent, check them before you connect.
Two alternatives if that matters:
- Use DeepSeek models through OpenRouter, which routes to several hosting providers. Check which provider serves your requests.
- Run DeepSeek’s open-weight models on your own hardware with Ollama, if your machine is big enough.
Contenox
Contenox takes the same key and lets you switch between DeepSeek and other providers per session, for example when DeepSeek is overloaded.
- Open Backends → Providers and, under Recommended, choose DeepSeek.
- Select Create key, create a key on the DeepSeek API keys page and copy it.
- Paste it into API Key, select Connect and wait for Connected.
- Pick a model in the Model chip on the message box. The Think chip sets how much it reasons.
To keep the key out of the app, enter DEEPSEEK_API_KEY under Advanced in
Environment variable name, set it with setx DEEPSEEK_API_KEY "your-key-here", and
reopen Contenox. Key rejected means a 401; use Replace to paste a new key.
Related
- Open-source AI coding agents: DeepSeek Harness next to OpenCode and others
- OpenRouter
- Ollama
- How to choose a model for coding
- AI coding costs
- Keep secrets away from AI agents