在 DeepSeek Harness 中接入 模驿API
DeepSeek Harness(命令名 dsh)支持配置 OpenAI 兼容的模型提供方。完成本节配置后,可以在 DeepSeek Harness 中通过 模驿API 调用 deepseek-flash、deepseek-v4-pro、deepseek-v4-flash、gpt-6-astra、gpt-5.6-sol 等模型,并继续使用 Harness 的 Web 界面、会话和 Agent 能力。
支持的模型
- DeepSeek:
deepseek-flash(DeepSeek V4.1 Flash)、deepseek-v4-pro(0813正式版)、deepseek-v4-flash(0731正式版) - GLM:
glm-5.3-flash - GPT:
gpt-6-astra、gpt-5.6-sol、gpt-5.6-luna、gpt-5.6-terra、gpt-5.5
1. 准备工作
开始前,请安装 Node.js 24,并准备好一个可用的 模驿API API Key。
1.1 安装 Node.js 24
DeepSeek Harness 要求使用 Node.js 24。npm 会随 Node.js 一起安装,请根据自己的操作系统和 CPU 架构下载安装包:
使用国内镜像时,请在目录中选择 v24.x.x 版本,再下载适合当前系统的安装包。安装完成后,重新打开终端并检查版本:
node --version
npm --version
node --version 的输出应以 v24. 开头。
1.2 准备 模驿API API Key
API Key 以 sk-moyiapi- 开头,可以在 模驿API 控制台创建。
2. 一键配置并启动
无需打开或手动修改任何配置文件。先在代码块中把 sk-moyiapi-请替换成你的真实Key 替换为你自己的 模驿API API Key,再复制整段命令到终端运行。命令会自动完成安装、配置并启动 DeepSeek Harness。
macOS / Linux
bash <<'MOYIAPI_SETUP'
set -e
npm install -g @deepseek-ai/dsh
MOYIAPI_API_KEY="sk-moyiapi-请替换成你的真实Key"
export MOYIAPI_API_KEY
NODE_PATH="$(npm root -g)/@deepseek-ai/dsh/node_modules" node <<'NODE'
const fs = require('fs');
const os = require('os');
const path = require('path');
const yaml = require('js-yaml');
const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
const settingsPath = path.join(home, 'settings.yaml');
fs.mkdirSync(home, { recursive: true });
const current = fs.existsSync(settingsPath)
? (yaml.load(fs.readFileSync(settingsPath, 'utf8')) || {})
: {};
if (fs.existsSync(settingsPath)) {
fs.copyFileSync(settingsPath, settingsPath + '.bak.' + Date.now());
}
current['llm-pi-ai'] ??= {};
current['llm-pi-ai'].providers ??= {};
current['llm-pi-ai'].providers.moyiapi = {
displayName: 'Moyi API',
apiKeyEnv: 'MOYIAPI_API_KEY',
api: 'openai-completions',
baseURL: 'https://api.moyiapi.cn/v1',
models: [
{ id: 'deepseek-flash', name: 'DeepSeek V4.1 Flash' },
{ id: 'deepseek-v4-pro', name: 'DeepSeek V4 Pro' },
{ id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash' },
{ id: 'gpt-6-astra', name: 'GPT 6 Astra' },
{ id: 'gpt-5.6-sol', name: 'GPT 5.6 Sol' },
{ id: 'gpt-5.6-luna', name: 'GPT 5.6 Luna' },
{ id: 'gpt-5.6-terra', name: 'GPT 5.6 Terra' },
{ id: 'gpt-5.5', name: 'GPT 5.5' },
],
};
current['agent-default-model'] = {
provider: 'moyiapi',
model: 'deepseek-flash',
};
fs.writeFileSync(
settingsPath,
yaml.dump(current, { lineWidth: -1, noRefs: true }),
{ mode: 0o600 },
);
const envPath = path.join(home, '.env');
const oldLines = fs.existsSync(envPath)
? fs.readFileSync(envPath, 'utf8').split(/\r?\n/)
: [];
const lines = oldLines.filter(
(line) => line && !line.startsWith('MOYIAPI_API_KEY='),
);
lines.push('MOYIAPI_API_KEY=' + process.env.MOYIAPI_API_KEY);
fs.writeFileSync(envPath, lines.join('\n') + '\n', { mode: 0o600 });
console.log('模驿API 配置完成,默认模型:deepseek-flash');
NODE
dsh web
MOYIAPI_SETUP
Windows PowerShell
npm install -g @deepseek-ai/dsh
$env:MOYIAPI_API_KEY = 'sk-moyiapi-请替换成你的真实Key'
$env:NODE_PATH = "$(npm root -g)\@deepseek-ai\dsh\node_modules"
@'
const fs = require('fs');
const os = require('os');
const path = require('path');
const yaml = require('js-yaml');
const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
const settingsPath = path.join(home, 'settings.yaml');
fs.mkdirSync(home, { recursive: true });
const current = fs.existsSync(settingsPath)
? (yaml.load(fs.readFileSync(settingsPath, 'utf8')) || {})
: {};
if (fs.existsSync(settingsPath)) {
fs.copyFileSync(settingsPath, settingsPath + '.bak.' + Date.now());
}
current['llm-pi-ai'] ??= {};
current['llm-pi-ai'].providers ??= {};
current['llm-pi-ai'].providers.moyiapi = {
displayName: 'Moyi API',
apiKeyEnv: 'MOYIAPI_API_KEY',
api: 'openai-completions',
baseURL: 'https://api.moyiapi.cn/v1',
models: [
{ id: 'deepseek-flash', name: 'DeepSeek V4.1 Flash' },
{ id: 'deepseek-v4-pro', name: 'DeepSeek V4 Pro' },
{ id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash' },
{ id: 'gpt-6-astra', name: 'GPT 6 Astra' },
{ id: 'gpt-5.6-sol', name: 'GPT 5.6 Sol' },
{ id: 'gpt-5.6-luna', name: 'GPT 5.6 Luna' },
{ id: 'gpt-5.6-terra', name: 'GPT 5.6 Terra' },
{ id: 'gpt-5.5', name: 'GPT 5.5' }
]
};
current['agent-default-model'] = {
provider: 'moyiapi',
model: 'deepseek-flash'
};
fs.writeFileSync(
settingsPath,
yaml.dump(current, { lineWidth: -1, noRefs: true }),
{ mode: 0o600 }
);
const envPath = path.join(home, '.env');
const oldLines = fs.existsSync(envPath)
? fs.readFileSync(envPath, 'utf8').split(/\r?\n/)
: [];
const lines = oldLines.filter(
(line) => line && !line.startsWith('MOYIAPI_API_KEY=')
);
lines.push('MOYIAPI_API_KEY=' + process.env.MOYIAPI_API_KEY);
fs.writeFileSync(envPath, lines.join('\n') + '\n', { mode: 0o600 });
console.log('模驿API 配置完成,默认模型:deepseek-flash');
'@ | node
if ($LASTEXITCODE -eq 0) {
dsh web
}
命令会自动完成安装、备份并合并现有配置、保存 Key、设置 模驿API 模型,然后启动 DeepSeek Harness。它不会删除已有的主题或其他设置。
启动成功后,终端会显示本地地址,默认通常为 http://127.0.0.1:3080。在浏览器打开该地址并新建会话即可使用。以后再次启动时,只需在项目目录运行:
dsh web
如需在指定项目中使用,请先进入项目的真实目录再运行 dsh web。不要直接照抄 /path/to/my-project,它只是占位符。
3. 验证接入
可以先用 Headless 模式发送一条最小请求,验证配置、Key 和模型是否都可用:
export MOYIAPI_API_KEY="sk-moyiapi-xxxxxx"
dsh --profile headless "只回复 OK"
如果终端返回 OK,说明 DeepSeek Harness 已经通过 模驿API 成功调用模型。随后运行 dsh web 即可进入 Web 界面。
4. 添加和切换其他模型
如果需要在 Harness 中选择多个 模驿API 模型,可以在同一个 models 列表中继续添加模型。以下示例同时提供 DeepSeek V4.1 Flash、DeepSeek V4 模型,以及多个 GPT 模型:
llm-pi-ai:
providers:
moyiapi:
displayName: Moyi API
apiKeyEnv: MOYIAPI_API_KEY
api: openai-completions
baseURL: https://api.moyiapi.cn/v1
models:
- id: deepseek-flash
name: DeepSeek V4.1 Flash
- id: deepseek-v4-pro
name: DeepSeek V4 Pro
- id: deepseek-v4-flash
name: DeepSeek V4 Flash
- id: gpt-6-astra
name: GPT 6 Astra
- id: gpt-5.6-sol
name: GPT 5.6 Sol
- id: gpt-5.6-luna
name: GPT 5.6 Luna
- id: gpt-5.5
name: GPT 5.5
- id: gpt-5.4
name: GPT 5.4
agent-default-model:
provider: moyiapi
model: deepseek-flash
修改 agent-default-model.model 可以更换新会话的默认模型。已经创建的会话可能继续沿用原模型,因此修改默认模型后,建议刷新页面并新建会话;也可以在界面的模型选择器中手动切换。
模型条目默认只接受文本。需要在对话里发送图片时,给支持图片的模型补一行 input: [text, image],否则 Harness 会提示「当前模型不支持图片,请切换支持图片的模型」。例如 DeepSeek V4.1 Flash、GLM 5.3 Flash:
models:
- id: deepseek-flash
name: DeepSeek V4.1 Flash
input: [text, image]
- id: glm-5.3-flash
name: GLM 5.3 Flash
input: [text, image]
deepseek-v4-flash 只接受文本,不要给它加 image。
模驿API 的模型列表会持续更新。需要确认实时模型 ID 时,可调用:
curl https://api.moyiapi.cn/v1/models \
-H "Authorization: Bearer sk-moyiapi-xxxxxx"
5. 常见问题
返回 401 或 invalid_bearer_token。 请确认 API Key 完整、没有多余空格、尚未被删除,并确认它以 sk-moyiapi- 开头。如仍失败,请在 模驿API 控制台新建 Key 后重试。
提示 MISSING_CREDENTIAL。 DSH 没有读取到 MOYIAPI_API_KEY。请在设置环境变量的同一个终端窗口中运行 dsh web,不要先关闭窗口再从其他位置启动。
提示未知模型或模型不在列表中。 请确认模型 ID 已写入 settings.yaml 的 models 列表,并通过 GET /v1/models 核对当前模型 ID。
修改默认模型后仍在使用旧模型。 默认模型只保证用于新会话。请新建会话,或在当前会话中手动切换模型。
发送图片时提示「当前模型不支持图片,请切换支持图片的模型」。 该模型条目没有声明图片输入。打开 ~/.dsh/settings.yaml(也可以在 Harness 界面进入 设置 → 模型 → 打开配置文件),给对应模型补一行 input: [text, image],保存后新建会话;如果模型选择器没有更新,重启 dsh web。写法见第 4 节。
端口 3080 已被占用。 可以改用其他端口:
dsh web --port 3081
GPT 的推理参数表现异常。 GPT 接入时不要在 模驿API provider 上配置 compat.thinkingFormat: deepseek。该字段用于 DeepSeek 模型的推理格式,不适用于 GPT。若同一 provider 同时配置 GPT 和 DeepSeek,应仅将该字段写在对应的 DeepSeek 模型条目下。
6. Key 安全
不要把真实 API Key 写入项目源码、提交到 Git、打包进前端应用或发送到公开聊天中。推荐通过 MOYIAPI_API_KEY 环境变量传入。若怀疑 Key 已泄露,请立即在 模驿API 控制台删除旧 Key 并创建新 Key。
相关文档:模驿API API 接入文档