---
title: "Claude Code 接入 DeepSeek 怎么配：10 月 17 日起 Claude Code、Codex、Harness 三种用法"
description: "截至 2026 年 10 月 17 日，DeepSeek 官方文档已给出 Claude Code 的环境变量和 Codex 的 config.toml 配置。本文按官方页面整理步骤，并说明 Harness 与搜索计费时间点。"
url: https://cdnping.org/blog/deepseek-claude-code-codex-harness
language: zh-CN
published: 2026-10-19
category: "开发工具"
tags: ["DeepSeek","Claude Code","Codex","DeepSeek Harness","API 接入"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# Claude Code 接入 DeepSeek 怎么配：10 月 17 日起 Claude Code、Codex、Harness 三种用法

Claude Code 接入 DeepSeek 不需要改工具本身：设置 `ANTHROPIC_BASE_URL` 指向 `https://api.deepseek.com/anthropic`，再把 `ANTHROPIC_AUTH_TOKEN` 换成 DeepSeek 的 API Key 即可。Codex 则从 2026 年 8 月 13 日起可以通过 Responses API 直接连 DeepSeek。10 月 17 日，DeepSeek 发布 DeepSeek-V4.1-Flash-1017，并建议使用 DeepSeek Harness 0.2.1-rc.1 或更高版本。

以下内容截至 2026 年 10 月 17 日，均来自 DeepSeek 官方文档，配置项以官方页面为准。

## 10 月 17 日 DeepSeek 发布了什么？

根据 [官方更新日志](https://api-docs.deepseek.com/updates) 和 [10 月 17 日公告](https://api-docs.deepseek.com/news/news261017)：

- 发布 DeepSeek-V4.1-Flash-1017，公告称已在网站、App 和 API 上线，并针对 DeepSeek Harness 等工具做了优化。
- Search 与 Fetch API 对所有人开放，公告写明每个接口每 1000 次调用 0.75 美元。
- 通过 DeepSeek Harness、Claude Code、Codex 的服务端工具发起的搜索调用，目前对 DeepSeek API 用户免费；公告写明从 2026 年 10 月 31 日 16:00 UTC 开始计费，换算成北京时间是 11 月 1 日 0 点。
- 官方建议升级到 DeepSeek Harness 0.2.1-rc.1 或更高版本。

Codex 的适配更早：[8 月 13 日的更新](https://api-docs.deepseek.com/updates)写明 DeepSeek API 原生支持 OpenAI Responses API 格式，并专门适配了 Codex。

## Claude Code 怎么接 DeepSeek？

[首页](https://api-docs.deepseek.com/) 列出两个入口：OpenAI 格式用 `https://api.deepseek.com`，Anthropic 格式用 `https://api.deepseek.com/anthropic`。Claude Code 走后者。

按 [官方 Claude Code 指南](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code)，已装好 Claude Code 的人只需设置环境变量（Linux/macOS）：

```bash
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<你的 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
```

然后 `cd` 到项目目录运行 `claude`。Windows PowerShell 的写法在官方页面上有对应版本。几点说明：

- API Key 在 [DeepSeek 开放平台](https://platform.deepseek.com/api_keys) 创建。
- 官方页面写明：模型名以 `claude-opus` 开头的会映射到 `deepseek-v4-pro`，按 Pro 价格计费；以 `claude-haiku` 或 `claude-sonnet` 开头的映射到 `deepseek-flash`。
- 想固定用哪个模型，就明确设置上面几个模型变量，不要依赖默认值。
- Claude Code 可以调用 DeepSeek 的联网搜索，这会额外产生模型 token 费用，搜索请求按 Search API 定价。

自定义接口地址在不同版本下的权限和上下文行为有差异，可以参考 [Claude Code 接自定义接口地址](/blog/claude-code-custom-base-url-third-party) 和 [自定义 API 与 Codex、OpenCode 接口地址配置](/blog/configure-custom-api-endpoint-claude-code-codex)。

## Codex 怎么用 DeepSeek？

[官方 Codex 指南](https://api-docs.deepseek.com/quick_start/agent_integrations/codex) 提供两种方式：

1. 脚本方式：官方提供 macOS/Linux 和 Windows 的配置脚本，脚本会把原有 `config.toml` 备份到 `~/.codex/backup-deepseek/`，菜单里可以选模型，也可以恢复原配置。运行网络上的脚本前，建议先下载下来看一遍内容。
2. 手动方式：创建 `~/.codex/models.json`（内容从官方页面复制），再编辑 `~/.codex/config.toml`。核心部分如下：

```toml
model = "deepseek-flash"
model_provider = "deepseek"

[model_providers.deepseek]
name = "deepseek"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
experimental_bearer_token = "<你的 DeepSeek API Key>"
```

官方完整示例还包含 `model_catalog_json`、`preferred_auth_method` 等设置，请以页面为准。如果你的配置文件里已经有 `[desktop]` 段，只追加官方示例里的那一行，重复段会让文件失效。启动后，横幅里应显示 `model: deepseek-flash`。

注意 `experimental_bearer_token` 是把 Key 明文写进配置文件，不要把这个文件提交到仓库或发给别人。官方页面还提到，示例默认关闭联网搜索（`web_search = "disabled"`），Codex 的联网搜索需要 `deepseek-v4-pro`，且按 Search API 计费。

## DeepSeek Harness 是什么？

官方公告没有给出定义。从 [Harness 快速入门页](https://deepseek-harness.github.io/deepseek-harness/en/guide/quickstart) 能确认的是：它有 Web UI，启动命令是 `dsh`，进程会把启动目录作为默认工作目录；在 Settings → Models 填入 DeepSeek API Key 后无需重启生效；选好工作区后，agent 可以读写文件、执行命令、委派任务并维护计划，受限操作会先请求批准。文档还提到 CLI、Python SDK 和插件开发指南。安装方式见项目 README，本文不展开。

## 怎么检查是否接通了？

| 现象 | 先查什么 |
| --- | --- |
| Claude Code 提示认证失败 | `ANTHROPIC_AUTH_TOKEN` 是否是 DeepSeek 的 Key，同一终端是否残留原来的 Anthropic 相关变量 |
| Codex 仍显示旧模型 | 修改后是否重启，横幅是否为 `model: deepseek-flash` |
| 请求超时或很慢 | 先排除网络，再看服务端 |
| 搜索产生费用 | 11 月 1 日（北京时间）前官方说明免费，之后按 Search API 计费 |

排查网络时，可以先打开 [cdnping 首页](/) 测 DeepSeek 的首次连接（含 DNS 与 TLS）和往返延迟，再看 [DeepSeek API 状态](/status/deepseek) 判断是不是服务端问题。国内延迟的判断思路见 [国内使用 AI API 指南](/blog/ai-api-guide-for-china-developers-2026) 和 [AI API 延迟](/learn/ai-api-latency-china)。

价格方面，DeepSeek 有高峰和错峰两档，错峰为高峰的一半，计算方式见 [高峰和错峰价格怎么算](/blog/deepseek-api-peak-offpeak-pricing)；搜索接口的调用方式见 [Search & Fetch API 怎么收费](/blog/deepseek-search-fetch-api-pricing)。

## 思考强度该选哪一档？

Codex 指南里的 `models.json` 声明的档位是 low、high、max。Claude Code 指南里默认示例是 `CLAUDE_CODE_EFFORT_LEVEL=max`，Codex 示例里是 `model_reasoning_effort = "high"`。我没有看到官方给出按任务选档的建议，可以自己用同一个任务各跑一次，对比耗时和 token 用量，不要凭感觉定。

## 同样只改接口地址的其他方式

如果你的需求是在一份订阅里切换多个模型，同样是改一个接口地址的思路也适用于 AGI Plan。AGI Plan 是 cdnping 的商业合作方，不是官方授权渠道，具体可用模型以 [agiplan.dev/models](https://agiplan.dev/models) 为准。这与直连 DeepSeek 是两条独立的路线，按自己的付费和合规需求选择即可。

## 参考来源

- [DeepSeek API 文档首页](https://api-docs.deepseek.com/)
- [DeepSeek 更新日志](https://api-docs.deepseek.com/updates)
- [2026-10-17 公告](https://api-docs.deepseek.com/news/news261017)
- [Claude Code 接入指南](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code)
- [Codex 接入指南](https://api-docs.deepseek.com/quick_start/agent_integrations/codex)
- [DeepSeek Harness 快速入门](https://deepseek-harness.github.io/deepseek-harness/en/guide/quickstart)
