claude-code-deepseek

Provides a complete plan for installing, configuring, and connecting Claude Code to the DeepSeek API. Uses DeepSeek’s Anthropic-compatible endpoint so no proxy is required, and supports one-click configuration to run Claude Code through the DeepSeek backend. Example trigger phrases: install Claude Code, Claude Code configure DeepSeek, claude-deepseek, Claude Code domestic use, Anthropic unavailable.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "claude-code-deepseek" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1c75e9d301d726ef2d1876e127ab09152dec11443085f1e4eb37f68436888bd7. Verify the upstream source and version against https://skillhub.cn/skills/user_3ba3a83b/claude-code-deepseek before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Provides a complete plan for installing, configuring, and connecting Claude Code to the DeepSeek API. Uses DeepSeek’s Anthropic-compatible endpoint so no proxy is required, and supports one-click configuration to run Claude Code through the DeepSeek backend. Example trigger phrases: install Claude Code, Claude Code configure DeepSeek, claude-deepseek, Claude Code domestic use, Anthropic unavailable.

0 Downloads

Introduction source: third_party · user_3ba3a83b · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: claude-code-deepseek
slug: claude-code-deepseek
displayName: "Claude Code 接入 DeepSeek"
version: "1.0.0"
description: "Claude Code 安装配置及接入 DeepSeek API 的完整方案。利用 DeepSeek 自带 Anthropic 兼容端点,无需自建代理,一键配置即可让 Claude Code 通过 DeepSeek 后端运行。触发词:安装 Claude Code、Claude Code 配置 DeepSeek、claude-deepseek、Claude Code 国内使用、Anthropic 不可用。"
author: lwm
agent_created: true
tags: [claude-code, deepseek, anthropic, setup, api, proxy, macos]

Claude Code 接入 DeepSeek 技能

问题背景

Claude Code 是 Anthropic 官方推出的命令行 AI 编程助手,能直接在终端中完成代码编写、调试、重构等任务。

在国内使用 Claude Code 面临以下问题:

  1. Anthropic API 不可用:Claude Code 默认连接 Anthropic 官方 API,国内无法直接访问
  2. 订阅限制:Claude Pro/Max 订阅需海外信用卡,且价格较高($20-$100/月)
  3. Claude Code 不原生支持 OpenAI 兼容 API:需要特殊适配

核心发现

DeepSeek 提供了 Anthropic Messages API 兼容端点:

https://api.deepseek.com/anthropic

这意味着 Claude Code 可以零代码修改直接对接 DeepSeek,只需配置环境变量即可。

方案架构

Claude Code CLI
    |
    | Anthropic Messages API 格式
    v
https://api.deepseek.com/anthropic  (DeepSeek Anthropic 兼容端点)
    |
    v
DeepSeek 后端模型 (deepseek-chat / deepseek-reasoner)
    |
    v
AI 回复

无需自建代理、无需格式转换、无需第三方工具。

前置条件

条件 最低版本 检查命令
Node.js 18+ node -v
npm 9+ npm -v
DeepSeek API Key 余额 > ¥0 从 https://platform.deepseek.com 获取

快速开始(一键配置)

第1步:安装 Claude Code

# 方式一:npm 全局安装(推荐)
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

# 方式二:如权限不足,先配置 npm prefix
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

# 验证安装
claude --version

第2步:运行一键配置脚本

bash ~/.workbuddy/skills/claude-code-deepseek/scripts/setup.sh "你的DeepSeek-API-Key"

脚本会自动:

  • 将环境变量写入 ~/.zshrc
  • 创建 claude 快捷命令(如需要)
  • 配置好所有必要的环境变量

第3步:启动使用

# 必须新开终端窗口
source ~/.zshrc
claude

环境变量说明

变量 值 说明
ANTHROPIC_BASE_URL https://api.deepseek.com/anthropic Claude Code 请求地址指向 DeepSeek
ANTHROPIC_AUTH_TOKEN sk-你的DeepSeek-Key 认证令牌
ANTHROPIC_MODEL deepseek-chat 主力模型
ANTHROPIC_DEFAULT_SONNET_MODEL deepseek-chat Sonnet 角色模型
ANTHROPIC_DEFAULT_HAIKU_MODEL deepseek-chat Haiku 角色模型
CLAUDE_CODE_SUBAGENT_MODEL deepseek-chat 子代理模型

手动配置(如不用脚本)

在 ~/.zshrc 末尾添加:

# ===== Claude Code + DeepSeek =====
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-你的DeepSeek-API-Key"
export ANTHROPIC_MODEL="deepseek-chat"
export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-chat"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-chat"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-chat"
# ===== END Claude Code + DeepSeek =====

模型选择

DeepSeek 模型 定位 建议用途
deepseek-chat 通用对话 日常编程(推荐)
deepseek-reasoner 深度推理 复杂问题分析

如需切换模型,修改环境变量中的 ANTHROPIC_MODEL 值即可。

常用 Claude Code 命令

claude                    # 启动交互式会话
claude "你的问题"          # 非交互式提问
claude -c                 # 继续上次对话
claude --model sonnet     # 指定模型(环境变量中配置)
claude --print "问题"     # 输出后退出(适合脚本调用)

测试验证

# 非交互式测试
claude --print "用一句话介绍你自己"

# 如回答正常,说明配置成功
# 预期输出: "我是 Claude..."

也可在 DeepSeek 控制台 https://platform.deepseek.com 查看 API 调用记录。

费用参考

DeepSeek 模型 输入价格 输出价格
deepseek-chat ¥1/百万token ¥2/百万token
deepseek-reasoner ¥4/百万token ¥16/百万token

典型单次对话成本:约 ¥0.01-0.05(取决于对话长度)

切换回官方 Anthropic(如有 Anthropic Key)

# 临时切换
unset ANTHROPIC_BASE_URL
unset ANTHROPIC_AUTH_TOKEN
claude  # 将使用 Anthropic 官方认证

# 永久切换:编辑 ~/.zshrc,删除或注释掉 Claude Code + DeepSeek 配置段

故障排查

"authentication failed"

  • 环境变量未生效,必须新开终端窗口
  • 检查 echo $ANTHROPIC_AUTH_TOKEN 是否输出你的 Key
  • 运行 source ~/.zshrc

"Claude isn't available in your region"

  • Claude Code 尝试连接了 Anthropic 官方,未使用代理
  • 检查 echo $ANTHROPIC_BASE_URL 是否输出 https://api.deepseek.com/anthropic

Claude Code 未找到命令

  • npm 全局安装路径不在 PATH 中
  • 运行 npm config get prefix 查看安装位置
  • 将 $(npm config get prefix)/bin 加入 PATH

npm 权限错误 (EACCES)

# 不要用 sudo,用以下方式
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
source ~/.zshrc

踩坑记录

不要自建代理

Claude Code 发送的是 Anthropic Messages API 格式(/v1/messages),而非 OpenAI 格式。 虽然可以自建代理做格式转换(Anthropic ↔ OpenAI),但:

  1. 增加了复杂度和故障点
  2. 流式 SSE 转换容易出错
  3. 沙箱/容器环境可能有网络限制

DeepSeek 自带 Anthropic 兼容端点是最佳方案。

npm cache 权限问题

macOS 上 npm cache 目录可能被 root 占用,导致全局安装失败:

Your cache folder contains root-owned files

解决(需要管理员权限):

sudo chown -R $(whoami) ~/.npm

或配置自定义 prefix 避开系统目录。

Python 代理方案不可行

尝试过用 Python(asyncio + httpx)自建代理服务器, 但沙箱环境中:

  • FastAPI/pydantic_core 因 Team ID 不匹配加载失败
  • 后台进程无法访问外网

结论:在沙箱受限环境中,直接使用云端兼容端点是唯一可行方案。

Bundled Resources

scripts/

文件 说明
setup.sh 一键配置脚本,自动写入环境变量到 ~/.zshrc

references/

文件 说明
alternatives.md 其他方案对比(自建代理、CC-Switch、ccproxy 等)

高级用法

多模型切换

在 ~/.zshrc 中配置切换函数:

# 切换到 DeepSeek
claude-deepseek() {
    export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
    export ANTHROPIC_AUTH_TOKEN="sk-你的Key"
    export ANTHROPIC_MODEL="deepseek-chat"
    claude "$@"
}

# 切换到智谱 GLM(也兼容 Anthropic)
claude-glm() {
    export ANTHROPIC_BASE_URL="https://open.bigmodel.cn/api/paas/anthropic"
    export ANTHROPIC_AUTH_TOKEN="你的智谱Key"
    export ANTHROPIC_MODEL="glm-4-flash"
    claude "$@"
}

使用免费模型替代

如不想使用收费的 DeepSeek,可尝试:

  • 智谱 GLM-4-Flash:永久免费,提供 Anthropic 兼容端点
  • 阿里云百炼:每日 146 模型试用免费额度

非交互式批量调用

# 适合自动化脚本
claude --print "分析这个项目的代码结构" > analysis.txt

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 解决国内用户无法使用 Anthropic API 的核心痛点
  • 提供零代码修改直接对接 DeepSeek 的高效方案
  • 内容详实,覆盖从安装到故障排查的完整流程
Trigger Precision95/100

Highlights

  • 触发词覆盖全面,包括安装、配置、国内使用等关键场景
  • 边界清晰,不易与其他 Skill 混淆
Structure and Standards94/100

Highlights

  • 文档结构完整,逻辑清晰,包含问题背景到高级用法的全链路说明
  • 提供端到端示例和具体命令,便于用户快速上手
Execution Reliability93/100

Areas to improve

  • 引用文件缺失 Reported severity: Minor

    SKILL.md 中引用了 scripts/setup.sh 和 references/alternatives.md 文件,但未在传入内容中提供这些文件

    Recommendation: 请确保所有被引用的文件都包含在 Skill 包中,或明确说明这些资源暂不可用

Highlights

  • 工具来源明确,参数配置正确
  • 覆盖了主要异常场景并提供解决方案
  • 提供一键配置脚本和手动配置两种方式,提升用户体验
Evidence Verifiability (mean of the first four)94/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • api.deepseek.com
  • open.bigmodel.cn
  • platform.deepseek.com
  • registry.npmmirror.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.