DeepSeek 模型配置
什么是 DeepSeek?
DeepSeek 是由深度求索(DeepSeek)公司开发的一系列高性能大语言模型。在 Codex 中配置 DeepSeek 模型,可以为您提供更多样化的 AI 编程辅助选择。DeepSeek 模型以其出色的代码理解和生成能力著称,同时在成本效益方面具有显著优势。
DeepSeek 模型系列
| 模型名称 | 特点 | 适用场景 |
|---|---|---|
| DeepSeek-V3 | 通用旗舰模型,强大的代码能力 | 日常开发、代码生成、重构 |
| DeepSeek-R1 | 推理增强模型,深度思考 | 复杂算法、调试、架构设计 |
| DeepSeek-Coder-V2 | 代码专项优化 | 代码补全、审查、文档生成 |
在 Codex 中配置 DeepSeek
获取 DeepSeek API Key
- 注册 DeepSeek 账号(访问 platform.deepseek.com)
- 在控制台中创建 API Key
- 复制 API Key 备用
方式一:环境变量配置
在 shell 配置文件中设置环境变量:
# ~/.zshrc 或 ~/.bashrc
export DEEPSEEK_API_KEY=sk-your_deepseek_api_key_here
方式二:Codex 全局配置文件
在 ~/.claude/settings.json 中配置:
{
"models": {
"default": "deepseek-chat",
"providers": {
"deepseek": {
"apiKey": "sk-your_deepseek_api_key_here",
"baseUrl": "https://api.deepseek.com/v1"
}
}
}
}
方式三:项目级配置
在项目目录下的 CLAUDE.md 中指定:
# 项目配置
此项目默认使用 DeepSeek 模型。
API 配置通过环境变量 DEEPSEEK_API_KEY 注入。
模型切换
启动时指定模型
# 使用 DeepSeek 启动 Codex
claude --model deepseek-chat
# 使用 DeepSeek-R1
claude --model deepseek-reasoner
对话中切换模型
在对话过程中,您可以通过斜杠命令切换模型:
/model deepseek-chat
/model deepseek-reasoner
使用场景对比
| 场景 | DeepSeek-V3 | DeepSeek-R1 | Claude |
|---|---|---|---|
| 日常编码 | 优秀 | 良好 | 优秀 |
| 复杂算法 | 良好 | 优秀 | 优秀 |
| 代码审查 | 优秀 | 良好 | 优秀 |
| 架构设计 | 良好 | 优秀 | 优秀 |
| 成本 | 低 | 中 | 中高 |
| 响应速度 | 快 | 中 | 快 |
多模型策略
您可以配置 Codex 在不同场景下使用不同的模型:
{
"models": {
"coding": "deepseek-coder",
"reasoning": "deepseek-reasoner",
"default": "claude-3-opus"
}
}
通过合理配置,您可以在保证代码质量的同时优化成本和响应速度。
常见问题
连接超时
# 检查网络连接
curl https://api.deepseek.com/v1/models
# 如果使用代理,确保正确配置
export HTTPS_PROXY=http://proxy:8080
Token 配额不足
DeepSeek API 有使用配额限制,建议:
- 在 DeepSeek 控制台查看当前使用量
- 设置月度预算上限
- 使用
/cost命令监控当前会话消耗