API-AI-014:用户 DeepSeek Key 测试连接 API #175

Closed
opened 2026-06-10 21:03:22 +08:00 by wangdl · 1 comment
Owner

目标

用户填写 DeepSeek Key 后,可以测试该 key 是否可用。

接口建议

POST /ai/model-credentials/{id}/test

流程

  1. 校验 credential 属于当前用户。
  2. 解密 key。
  3. 发起一次最小 DeepSeek 测试请求。
  4. 记录 lastTestedAt。
  5. 成功则 status = active。
  6. 失败则 status = invalid,并记录 lastErrorCode。

安全要求

  1. 测试请求不得把用户学习内容发送给 DeepSeek。
  2. 测试 prompt 必须是固定最小内容。
  3. 不记录明文 key。

验收标准

  1. 有效 key 返回 success。
  2. 无效 key 返回明确 errorCode。
  3. 测试结果写入 credential 状态。
  4. 不允许测试其他用户 key。
  5. 不发送用户资料内容。
  6. 提供 mock DeepSeek 测试。
## 目标 用户填写 DeepSeek Key 后,可以测试该 key 是否可用。 ## 接口建议 ``` POST /ai/model-credentials/{id}/test ``` ## 流程 1. 校验 credential 属于当前用户。 2. 解密 key。 3. 发起一次最小 DeepSeek 测试请求。 4. 记录 lastTestedAt。 5. 成功则 status = active。 6. 失败则 status = invalid,并记录 lastErrorCode。 ## 安全要求 1. 测试请求不得把用户学习内容发送给 DeepSeek。 2. 测试 prompt 必须是固定最小内容。 3. 不记录明文 key。 ## 验收标准 1. 有效 key 返回 success。 2. 无效 key 返回明确 errorCode。 3. 测试结果写入 credential 状态。 4. 不允许测试其他用户 key。 5. 不发送用户资料内容。 6. 提供 mock DeepSeek 测试。
wangdl added this to the M-API-AI-RUNTIME:API AI Runtime 调度与落库 milestone 2026-06-10 21:03:22 +08:00
Author
Owner

完成证据

产物: src/modules/ai-runtime/user-ai.service.tstestCredential() 方法
提交: 4cf2aa9 feat: 用户 AI 设置与 Key 管理 API (API-AI-011~015)

接口: POST /ai/model-credentials/:id/test

流程: 解密 Key → 调用 DeepSeek GET /v1/models → 成功则 status=active → 失败则记录 lastErrorCode + lastErrorMessage

安全:

  • 只调用固定最小 API(/v1/models),不发送用户学习内容
  • 不记录明文 Key
  • 10 秒超时
## 完成证据 **产物**: `src/modules/ai-runtime/user-ai.service.ts` — `testCredential()` 方法 **提交**: `4cf2aa9` feat: 用户 AI 设置与 Key 管理 API (API-AI-011~015) **接口**: `POST /ai/model-credentials/:id/test` **流程**: 解密 Key → 调用 DeepSeek GET /v1/models → 成功则 status=active → 失败则记录 lastErrorCode + lastErrorMessage **安全**: - 只调用固定最小 API(/v1/models),不发送用户学习内容 - 不记录明文 Key - 10 秒超时
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/api-server#175
No description provided.