DeepSeek coding agent: API key, models and setup
Updated Fact-checked
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 Harness 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 → enter your key |
Select your model in /models. |
| Contenox Harness | 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#
In the OpenCode terminal, enter /connect, select DeepSeek, and enter your DeepSeek API key. Open /models to choose a model from that provider. OpenCode Go offers a separate way to use the models included in its plan. OpenCode providers
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 Harness#
Contenox Harness 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 Harness. Key rejected means a 401; use Replace to paste a new key.
Related#
Open-source AI coding agents: DeepSeek Harness next to OpenCode and othersOpen source AI coding agents in 2026: every license checkedEvery notable open source AI coding agent with its license, interface and models, checked November 2026, plus what open source does and doesn't get you.
OpenRouterOpenRouter coding agent: Claude Code, Codex, OpenCode setupUse OpenRouter with a coding agent: setup for Claude Code, Codex CLI and OpenCode, a capped API key, models that call tools well, and 401 and 402 fixes.
OllamaSet up an Ollama coding agent on Windows, Mac or LinuxSet up an Ollama coding agent in Contenox on Windows, macOS or Linux. Install Ollama, download a chat model, check the connection and send your first message.
How to choose a model for codingHow to compare AI coding models on your own codebaseCompare AI coding models on five tasks from your repository. Score each run on passing tests, unnecessary edits, elapsed time and cost per finished task.
AI coding costsAI coding costs: why agents burn tokens and how to cut itAI coding costs explained: why one agent session can send hundreds of millions of tokens, what sessions really cost, and the habits that cut the bill.
Keep secrets away from AI agentsHow to keep secrets away from AI agents (and out of git)How to keep secrets away from AI agents: block .env reads in Claude Code, OpenCode and Codex, stop keys leaking through commands, and what to do if one leaked.
ChatGPT subscriptionUse your ChatGPT subscription for a coding agent | ContenoxUse your ChatGPT subscription for a coding agent. Set up device sign-in in Contenox or use Codex on desktop, in an editor or in the terminal. Check plan limits.
GitHub Copilot subscriptionUse your GitHub Copilot subscription in other coding agentsUse your GitHub Copilot subscription outside VS Code: sign-in steps for OpenCode, Codex and Contenox Harness, which plans you need, and how AI Credits are billed.
Anthropic (Claude)Claude coding agent on Windows: API key setup | ContenoxRun a Claude coding agent on Windows: Claude Code with a subscription or API key, OpenCode with a key, why Codex can't, plus models, billing and key errors.
GeminiGemini coding agent: API key, free tier and setup | ContenoxSet up a Gemini coding agent: AI Studio key in OpenCode, Antigravity CLI or Contenox Harness, why Claude Code and Codex can't, free-tier data use, models and 429 fixes.