Appearance
OpenClaw 接入 DeepSeek 大模型完整教程(2026 最新版)
DeepSeek 已成为 OpenClaw 的一级公民。得益于社区版源码改造,现在无需繁琐配置 baseUrl,原生支持 DeepSeek-V3 / R1。这篇教程覆盖两种配置方法,帮你 2 分钟搞定。
为什么选 DeepSeek?
| 对比项 | DeepSeek | GPT-4 | Claude |
|---|---|---|---|
| 价格 | ¥1/百万 tokens | $10/百万 tokens | $15/百万 tokens |
| 上下文 | 64K | 128K | 200K |
| 中文能力 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 编程能力 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 国内访问 | ✅ 直连 | ❌ 需代理 | ❌ 需代理 |
DeepSeek 优势:
- 价格是 GPT-4 的 1/10
- 国内可直接访问
- 中文理解能力极强
- 编程能力一流
Step 1:获取 DeepSeek API Key
注册账号
- 打开 platform.deepseek.com
- 点击【注册】
- 支持手机号、微信、邮箱注册
创建 API Key
- 登录后进入【API Keys】页面
- 点击【创建 API Key】
- 复制保存 Key(只显示一次)
格式示例:
sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx免费额度
新用户送 500 万 tokens,足够测试使用。
Step 2:配置 OpenClaw
OpenClaw CN 版原生支持 DeepSeek,有两种配置方式。
方法一:交互式向导(推荐新手)
运行配置向导:
bash
openclaw config wizard按提示选择:
? 请选择要配置的模型提供商:
❯ DeepSeek # 选择这一项
? 请输入 DeepSeek API Key:
sk-xxxxxxxx # 粘贴你的 Key
? 请选择默认模型:
❯ deepseek-chat # 对话模型
deepseek-reasoner # 推理模型 R1完成后自动保存配置。
方法二:手动修改配置文件
适合熟悉配置文件的用户。
找到配置文件:
bash
# Linux/Mac
~/.openclaw/openclaw.json
# Windows
C:\Users\用户名\.openclaw\openclaw.json添加配置:
json
{
"models": {
"providers": {
"deepseek": {
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "deepseek/deepseek-chat"
}
}
}
}模型选择:
| 模型 | 用途 | 价格 |
|---|---|---|
| deepseek-chat | 日常对话、编程 | ¥1/百万 tokens |
| deepseek-reasoner | 复杂推理(R1) | ¥4/百万 tokens |
方法三:命令行直接配置
bash
# 设置 API Key
openclaw config set models.providers.deepseek.apiKey "sk-xxxxx"
# 设置默认模型
openclaw config set agents.defaults.model.primary "deepseek/deepseek-chat"Step 3:验证配置
检查配置
bash
# 查看 API Key 是否设置成功
openclaw config get models.providers.deepseek.apiKey
# 查看默认模型
openclaw config get agents.defaults.model.primary测试调用
bash
# 启动 OpenClaw
openclaw start
# 发送测试消息
# "请介绍一下你自己"如果返回正常回复,说明配置成功。
DeepSeek 模型详解
deepseek-chat(V3)
适用场景:
- 日常对话
- 文本生成
- 代码编写
- 翻译润色
特点:
- 速度快
- 成本低
- 中文能力强
deepseek-reasoner(R1)
适用场景:
- 复杂推理
- 数学问题
- 逻辑分析
- 深度思考
特点:
- 推理能力强
- 会展示思考过程
- 成本较高
模型路由配置
根据任务复杂度自动选择模型:
json
{
"modelRouting": {
"simple": "deepseek/deepseek-chat",
"complex": "deepseek/deepseek-reasoner",
"code": "deepseek/deepseek-chat"
}
}常见问题排查
问题一:Unknown model 错误
症状:
Error: Unknown model: deepseek-chat原因: 模型名称格式错误
解决:
OpenClaw 使用 提供商/模型名 格式:
json
{
"agents": {
"defaults": {
"model": {
"primary": "deepseek/deepseek-chat" // 正确
// "primary": "deepseek-chat" // 错误
}
}
}
}问题二:API Key 无效
症状:
Error: Invalid API key解决:
- 检查 Key 是否完整复制
- 检查 Key 是否过期
- 去 DeepSeek 平台重新生成
问题三:请求超时
症状:
Error: Request timeout解决:
- 检查网络连接
- 增加超时时间:
json
{
"models": {
"providers": {
"deepseek": {
"apiKey": "sk-xxxxx",
"timeout": 60000
}
}
}
}问题四:余额不足
症状:
Error: Insufficient balance解决:
去 DeepSeek 平台充值,最低 10 元起充。
成本优化建议
控制上下文长度
json
{
"agents": {
"defaults": {
"context": {
"maxMessages": 20
}
}
}
}启用缓存
json
{
"cache": {
"enabled": true,
"ttl": 3600
}
}监控用量
bash
# 查看今日用量
openclaw stats --today
# 查看本月用量
openclaw stats --month与其他模型对比
| 场景 | 推荐 | 原因 |
|---|---|---|
| 日常对话 | DeepSeek V3 | 性价比最高 |
| 复杂推理 | DeepSeek R1 | 推理能力强 |
| 英文任务 | GPT-4 | 英文能力更强 |
| 超长上下文 | Claude | 支持 200K |
| 本地离线 | Ollama | 完全免费 |
混合配置示例
同时使用多个模型:
json
{
"models": {
"providers": {
"deepseek": {
"apiKey": "sk-xxxxx"
},
"openai": {
"apiKey": "sk-xxxxx"
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "deepseek/deepseek-chat",
"fallback": "openai/gpt-4o"
}
}
}
}总结
| 步骤 | 操作 |
|---|---|
| 1 | 去 platform.deepseek.com 获取 API Key |
| 2 | 运行 openclaw config wizard 选择 DeepSeek |
| 3 | 粘贴 API Key,选择模型 |
| 4 | 测试验证 |
关键点:
- OpenClaw CN 原生支持 DeepSeek
- 模型名格式:
deepseek/deepseek-chat - 新用户有 500 万 tokens 免费额度
DeepSeek 是国内用户最推荐的模型选择:便宜、快速、中文能力强。配合 OpenClaw 的智能体能力,可以构建高性价比的 AI 助手。
