GitHub周趋势2026W25 | Headroom 压缩 95% Token、NVIDIA 开源 AI Agent 安全扫描器、…
2026-07-28
2026-08-03 0
OpenClaw使用DeepSeek官方API_KEY配置超详细操作步骤的重点在于把前置条件、操作顺序和容易误判的地方分清楚。
找遍全网也没找到如何在openclaw配置deepseek官方apikey,那我自己整一个,以下内容为Claude Code根据我的聊天记录总结生成,希望对想在openclaw使用deepseek官方apikey的人提供帮助。

npm install -g openclaw@latest
安装过程可能需要 3-5 分钟,会下载约 674 个依赖包。
openclaw --version
应该显示类似:? OpenClaw 2026.2.9
openclaw onboard --install-daemon --non-interactive --accept-risk
说明:
--install-daemon: 安装后台服务--non-interactive: 非交互模式--accept-risk: 接受安全风险声明openclaw status
确认 Gateway 服务正在运行。
访问 DeepSeek 官网 注册并获取 API Key。
API Key 格式类似:sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
执行以下命令(将 你的API_KEY 替换为实际的 API Key):
openclaw config set models.providers.deepseek '{ "baseUrl": "https://api.deepseek.com/v1", "apiKey": "你的API_KEY", "api": "openai-completions", "models": [ { "id": "deepseek-chat", "name": "DeepSeek Chat (V3)" }, { "id": "deepseek-reasoner", "name": "DeepSeek Reasoner (R1)" } ]}'openclaw config set agents.defaults.model.primary "deepseek/deepseek-chat"
openclaw models aliases add deepseek-v3 "deepseek/deepseek-chat"openclaw models aliases add deepseek-r1 "deepseek/deepseek-reasoner"
openclaw gateway restart
等待 3-5 秒让服务完全启动。
openclaw agent --session-id test --message "你好,请介绍一下你自己"
如果配置成功,DeepSeek 会用中文回复。
openclaw dashboard
浏览器会自动打开控制面板,URL 格式:
http://127.0.0.1:18789/#token=你的gateway_token
openclaw models status
应该显示:
deepseek/deepseek-chat# 启动 Gatewayopenclaw gateway# 重启 Gatewayopenclaw gateway restart# 停止 Gatewayopenclaw gateway stop# 查看服务状态openclaw status# 查看详细状态openclaw status --all# 查看实时日志openclaw logs --follow
# 列出所有可用模型openclaw models list --all# 查看当前模型配置openclaw models status# 切换模型(在聊天中使用)/model deepseek-v3# 设置默认模型openclaw config set agents.defaults.model.primary "模型ID"# 添加模型别名openclaw models aliases add 别名 "模型ID"# 查看所有别名openclaw models aliases list
# 发送单条消息openclaw agent --session-id 会话ID --message "你的问题"# 指定超时时间(秒)openclaw agent --session-id test --message "问题" --timeout 60# 使用本地模式(不通过 Gateway)openclaw agent --local --session-id test --message "问题"
# 查看配置openclaw config get 配置路径# 设置配置openclaw config set 配置路径 "值"# 删除配置openclaw config unset 配置路径# 运行配置向导openclaw configure
错误信息: disconnected (1008): unauthorized: gateway token missing
解决方法:
# 打开带 token 的控制面板openclaw dashboard
或手动获取 token:
openclaw config get gateway.auth.token
错误信息: Unknown model: xxx
解决方法:
检查模型配置:
openclaw models status
确认模型 ID 正确:
openclaw models list --all | grep deepseek
重启 Gateway:
openclaw gateway restart
错误信息: HTTP 401 或 Unauthorized
解决方法:
openclaw config set models.providers.deepseek.apiKey "新的API_KEY"openclaw gateway restart
错误信息: Request timed out 或 No reply from agent
解决方法:
curl -I https://api.deepseek.com/v1/models
openclaw agent --session-id test --message "测试" --timeout 120
解决方法:
检查端口占用:
lsof -i :18789
强制重启:
openclaw gateway --force
查看日志:
openclaw logs
运行诊断:
openclaw doctoropenclaw doctor --fix
当主模型不可用时,自动切换到备用模型:
openclaw config set agents.defaults.model.fallbacks '["deepseek/deepseek-reasoner"]'
将以下内容添加到 ~/.zshrc 或 ~/.bashrc:
# DeepSeek API Key (可选,如果已在配置文件中设置)export DEEPSEEK_API_KEY="你的API_KEY"# OpenClaw Gateway Token (可选)export OPENCLAW_TOKEN="你的gateway_token"
然后重新加载配置:
source ~/.zshrc # 或 source ~/.bashrc
openclaw config set agents.defaults.workspace "/自定义/工作空间/路径"
提示: 如果遇到其他问题,可以运行 openclaw doctor --deep 进行深度诊断,或访问官方文档获取更多帮助。