跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.mirobody.ai/llms.txt

Use this file to discover all available pages before exploring further.

此接口需要 LLM 凭证。 调用时需在 Authorization 之外额外携带 X-LLM-ProviderX-LLM-Api-Key header,详见 BYOK 协议

端点

POST /api/chat
Authorization:   Bearer <access_token>
X-LLM-Provider:  dashscope | volcengine | openai | gemini
X-LLM-Api-Key:   <您的 LLM Key>
Content-Type:    application/json
返回 SSE 流式 (text/event-stream)。

请求体

字段类型必填说明
questionstring用户提问;空字符串会被拒绝
agentstring国内固定为 App
providerstringLLM 选型,见 Provider 列表
session_idstring维持上下文。不传时后端自动生成并通过首条 id 事件下发
prompt_namestring启用通过 /api/user/prompt/set 保存的自定义 system prompt
query_user_idstring询问 家人 的健康数据,需共享权限
file_listarray携带文件提问,详见 携带文件
languagestringzh-CN / en;缺省走 Header X-Language → 用户 profile
timezonestringAsia/Shanghai

Provider 列表

国内 5 个 provider,全部支持多轮上下文、流式输出与工具调用:
provider底层模型适用场景
DeepSeekFlashDeepSeek v4 Flash默认首选,响应快、成本低
DeepSeekProDeepSeek v4 Pro复杂分析、需要更深推理
kimiKimi K2.6长上下文友好
minimaxMiniMax M2.7中文表达自然
豆包豆包 Doubao Seed 2.0 Lite中文场景备选,走火山引擎
GET /api/providers 可在运行时获取当前列表。

携带文件

file_list 五个字段全部必填 —— file_url / file_name / file_key / file_type / file_size。建议直接复用 POST /files/upload 返回的 data 数组:
"file_list": [
  {
    "file_url":  "<signed CDN URL returned by /files/upload>",
    "file_name": "report.pdf",
    "file_key":  "uploads/20260522_xxx.pdf",
    "file_type": "application/pdf",
    "file_size": 102400
  }
]
file_url 必须是 /files/upload 返回的完整带签名 URL,LLM 下游会真正去下载;剥掉签名参数会 403。

SSE 事件类型

每条事件:
data: {"type": "...", "content": ..., "tool_id": "?", "is_delete": null}\n\n
type时机content
id流首条web_<uuid> —— 本轮提问的 message id
queryTitle工具调用 / 阶段标题工具名或阶段描述
queryDetail工具调用结果字符串(一般是 JSON 化的工具返回)
reply模型答复增量文本片段 —— 前端需拼接
thinking内部思考文本片段
costStatistics临近结束{ model, input_tokens, output_tokens, total_tokens, total_cost }
error异常错误描述
end流结束
tool_id 用于关联同一次工具调用的 queryTitle / queryDetail

Agent 可调用的工具

Agent 按需调用健康 / 文件 / 图表工具,例如:
  • user-get_profileuser-search_health_indicatorsuser-fetch_health_datauser-get_genetic_datauser-get_journal_entries
  • file-list_global_filesfile-lsfile-fetch_remote_filesfile-read_file
  • 图表工具:line / column / pie / radar / dual-axes / scatter / boxplot / sankey / 等
  • data-search_medical_literaturedata-get_fda_drugsdata-search_clinical_trials

国内未开放的工具

国内集群通过 CHAT_DISALLOWED_TOOLS 关闭了以下工具,Agent 不会调用它们:
  • tool-*(全部 tool- 前缀工具,主要是 Apple Watch / 医生推荐)
  • user-get_eventsuser-get_food_recordsuser-list_medicationsuser-get_medication_details
如用户问”我最近吃了什么 / 在吃什么药 / 推荐医生”,Agent 不会自动取数据——请通过专用 REST 接口拉数据由前端展示。

实测示例

curl -N -X POST https://mcp.thetahealth.cn/api/chat \
  -H "Authorization: Bearer $TOKEN" \
  -H "X-LLM-Provider: dashscope" \
  -H "X-LLM-Api-Key: $LLM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question":"你好","agent":"App","provider":"DeepSeekFlash"}'
节选输出:
data: {"type": "id", "content": "web_223aa2af-..."}
data: {"type": "reply", "content": "你好呀!..."}
data: {"type": "costStatistics", "content": {"model": "dashscope/deepseek-v4-flash", ...}}
data: {"type": "end", "content": ""}