Claude Code with DeepSeek: Setup for Claude Code, Codex, Harness
You don't need to modify Claude Code to use DeepSeek. Set ANTHROPIC_BASE_URL to https://api.deepseek.com/anthropic, then replace ANTHROPIC_AUTH_TOKEN with your DeepSeek API key. Codex has been able to connect to DeepSeek directly through the Responses API since August 13, 2026. On October 17, DeepSeek released DeepSeek-V4.1-Flash-1017 and recommended DeepSeek Harness 0.2.1-rc.1 or later.
Everything below is current as of October 17, 2026 and comes from DeepSeek's official documentation. Treat the official pages as the source of truth for configuration options.
What did DeepSeek release on October 17?
According to the official changelog and the October 17 announcement:
- DeepSeek-V4.1-Flash-1017 is out. The announcement says it is live on the website, the app, and the API, and tuned for tools such as DeepSeek Harness.
- The Search and Fetch APIs are open to everyone. The announcement lists a price of $0.75 per 1,000 calls for each endpoint.
- Search calls made through the server-side tools of DeepSeek Harness, Claude Code, and Codex are currently free for DeepSeek API users. Billing starts at 16:00 UTC on October 31, 2026, which is midnight on November 1 in Beijing time.
- DeepSeek recommends upgrading to DeepSeek Harness 0.2.1-rc.1 or later.
Codex support came earlier. The August 13 update states that the DeepSeek API natively supports the OpenAI Responses API format and has been adapted specifically for Codex.
How do I connect Claude Code to DeepSeek?
The docs home page lists two entry points: https://api.deepseek.com for the OpenAI format and https://api.deepseek.com/anthropic for the Anthropic format. Claude Code uses the second one.
Per the official Claude Code guide, if Claude Code is already installed you only need to set these environment variables (Linux/macOS):
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
export CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432
Then cd into your project directory and run claude. The official page has a Windows PowerShell version as well. A few notes:
- Create your API key on the DeepSeek Platform.
- The official page says that model names starting with
claude-opusmap todeepseek-v4-proand are billed at Pro prices, while names starting withclaude-haikuorclaude-sonnetmap todeepseek-flash. - If you want a specific model, set the model variables above explicitly instead of relying on defaults.
- Claude Code can call DeepSeek's web search. This incurs additional model token charges, and the search requests themselves are billed at Search API prices.
Permission and context behavior for custom base URLs varies between versions. See Claude Code with a custom base URL and Configuring custom API endpoints for Claude Code, Codex, and OpenCode.
How do I use DeepSeek with Codex?
The official Codex guide offers two approaches:
- Script: DeepSeek provides setup scripts for macOS/Linux and Windows. The script backs up your existing
config.tomlto~/.codex/backup-deepseek/, lets you pick a model from a menu, and can restore your original config. Before running any script from the internet, download it and read it first. - Manual: create
~/.codex/models.json(copy the contents from the official page), then edit~/.codex/config.toml. The core of it looks like this:
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 official example also includes settings such as model_catalog_json and preferred_auth_method, so follow the page. If your config file already has a [desktop] section, add only the single line from the official example. A duplicate section will break the file. After launch, the banner should show model: deepseek-flash.
Note that experimental_bearer_token writes your key into the config file in plain text. Don't commit this file to a repository or share it. The official page also mentions that the example disables web search by default (web_search = "disabled"), and that web search in Codex requires deepseek-v4-pro and is billed at Search API prices.
What is DeepSeek Harness?
The official announcement doesn't define it. What the Harness quickstart page does confirm: it has a web UI, the launch command is dsh, and the process uses the directory it was started in as the default working directory. After you enter a DeepSeek API key under Settings → Models, it takes effect without a restart. Once you pick a workspace, the agent can read and write files, run commands, delegate tasks, and maintain a plan, and restricted actions ask for approval first. The docs also mention a CLI, a Python SDK, and a plugin development guide. For installation, see the project README; this article doesn't cover it.
How do I check that it's working?
| Symptom | What to check first |
|---|---|
| Claude Code reports an authentication failure | Whether ANTHROPIC_AUTH_TOKEN holds your DeepSeek key, and whether leftover Anthropic variables remain in the same terminal |
| Codex still shows the old model | Whether you restarted after the change, and whether the banner shows model: deepseek-flash |
| Requests time out or are slow | Rule out your network first, then look at the service side |
| Search generates charges | DeepSeek says search is free until November 1 (Beijing time); after that it is billed at Search API prices |
To troubleshoot the network, open the cdnping home page and measure DeepSeek's first-connection time (including DNS and TLS) and round-trip latency, then check DeepSeek API status to see whether the problem is on the service side. For how to judge latency from mainland China, see the guide to using AI APIs from China and AI API latency.
On pricing, DeepSeek has peak and off-peak rates, with off-peak at half the peak price. See how peak and off-peak pricing works for the calculation, and Search & Fetch API pricing for how to call the search endpoints.
Which reasoning effort level should I pick?
The models.json in the Codex guide declares the levels low, high, and max. The default example in the Claude Code guide uses CLAUDE_CODE_EFFORT_LEVEL=max, and the Codex example uses model_reasoning_effort = "high". I haven't seen official guidance on choosing a level per task. Run the same task once at each level and compare time and token usage rather than going by feel.
Other ways to change just one endpoint
If you want to switch between several models under one subscription, the same change-one-endpoint approach works with AGI Plan. AGI Plan is a commercial partner of cdnping, and it is not an officially authorized channel for any model vendor. Which models are available is listed at agiplan.dev/models. This is a separate route from connecting to DeepSeek directly, so choose based on your own payment and compliance needs.