mosoodocs
简体中文

Files

上传文件并挂载到 Mosoo API Thread。

通过公开 API 上传的文件是作用于 Agent API Endpoint App 的 draft file resource。创建 Thread 或发送用户消息时挂载它们。Agent 生成的文件是 artifact。只要 API token 调用方可见,它们都会出现在 Thread file list 中。

上传流程

公开上传使用 multipart/form-data,文件大小上限是 67108864 字节。

  1. POST /agents/{agentId}/files 把文件上传到 Agent。
  2. 保存返回的 file.id
  3. 创建 Thread 或发送后续用户消息时,通过 resources 挂载该文件。

上传文件

printf 'Customer asks for an implementation plan.' > brief.txt

curl -X POST "https://try.mosoo.ai/api/v1/agents/$MOSOO_AGENT_ID/files" \
  -H "Authorization: Bearer $MOSOO_API_TOKEN" \
  -F "file=@brief.txt;type=text/plain"

响应是 PublicFileResponse。保存其中的 file.id

{
  "file": {
    "id": "01J0000000000000000000000J",
    "name": "brief.txt",
    "mimeType": "text/plain",
    "size": 41,
    "createdAt": "2026-05-19T00:02:00.000Z"
  }
}

在首条消息中使用文件

curl -X POST "https://try.mosoo.ai/api/v1/agents/$MOSOO_AGENT_ID/threads" \
  -H "Authorization: Bearer $MOSOO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "resources": [
      {
        "type": "file",
        "file_id": "01J0000000000000000000000J"
      }
    ],
    "input": {
      "type": "user.message",
      "content": [
        {
          "type": "text",
          "text": "Summarize the attached file."
        }
      ]
    }
  }'

在后续消息中使用文件

后续用户消息通过 resources 发送文件 ID:

{
  "events": [
    {
      "type": "user_message",
      "resources": [
        {
          "type": "file",
          "file_id": "01J0000000000000000000000J"
        }
      ],
      "text": "Summarize the attached file."
    }
  ]
}

On this page