Lovely Router文档
获取密钥
浏览器智能体

文件上传

只需上传一次文件,再让运行使用它们,智能体会为每个上传字段附加正确的文件。

表单经常要求上传文件:简历、证件扫描件、发票。你只需把文件上传到 Lovely Router 一次。当运行可以使用这些文件时,智能体会为每个上传字段附加合适的文件:在“Resume”字段放你的简历而不是求职信,即使两者都是 PDF。

上传文件#

把原始字节发送到 PUT /v1/browser/files/{name},并用 Content-Type 指定文件类型。可选的 description 查询参数能帮助智能体做选择。

curl -X PUT "https://lovelyrouter.com/v1/browser/files/Maria_Garcia_CV_2026.pdf?description=Resume%2C%20updated%202026" \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/pdf" \
  --data-binary @Maria_Garcia_CV_2026.pdf

也可以向 POST /v1/browser/files 发送 multipart 表单,文件放在 file 字段中。name(默认为上传文件的文件名)和 description 是可选字段:

cURL
curl https://lovelyrouter.com/v1/browser/files \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -F "file=@Maria_Garcia_CV_2026.pdf;type=application/pdf" \
  -F "description=Resume, updated 2026"

两种方式都会返回已保存的文件:

JSON
{
  "id": "file_7a3c9e1b5d2f8a4c6e0b",
  "name": "Maria_Garcia_CV_2026.pdf",
  "mime": "application/pdf",
  "bytes": 84213,
  "sha256": "5f2b8c…",
  "description": "Resume, updated 2026",
  "created_at": "2026-10-11T09:20:44.000Z",
  "last_used_at": null
}

如果没有 Content-Type,文件会以 application/octet-stream 保存;请发送真实的类型,让智能体和网站都能识别。用相同的名称再次上传会替换文件并保留其 id。文件采用静态加密,与保险库密钥一样。Python 和 Node.js 示例沿用运行你的第一个任务中的 API、H 和 headers 设置。

限制值
文件大小10 MB
每个账户的文件数100
名称1 到 128 个字符:字母、数字、空格和 . _ - ( ) + ,,以字母、数字或 _ 开头
描述300 个字符(超出部分会被截断)

让运行使用你的文件#

启动运行时传入 files:文件名或 id 的列表,或用 "*" 表示你的所有文件。

cURL
curl https://lovelyrouter.com/v1/browser/runs \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "goal": "Apply for the Backend Engineer role as Maria Garcia (maria.garcia@example.com), based in Portland, Oregon. Attach her resume. Submit the application and tell me the application ID.",
    "start_url": "https://jobs.example.com/backend-engineer/apply",
    "files": ["Maria_Garcia_CV_2026.pdf", "Maria_Garcia_Cover_Letter.pdf"],
    "max_steps": 40
  }'

只有传入了 files 的运行才能附加文件,而且只能附加列出的文件。未知的名称会返回 400,错误为 Unknown file(s): CV.pdf. Upload with PUT /v1/browser/files/{name}.

在步骤记录中,上传步骤的 action 以 upload: 开头,其 description 写明对应的字段。如果运行在提交前暂停等待你批准,needs.fields 会显示附加了哪个文件,例如 Resume: file "Maria_Garcia_CV_2026.pdf"。

智能体如何选择文件#

在每个上传字段,智能体都会把你的文件与该字段的要求进行比较。它会查看:

  • 每个文件的名称、类型、大小和描述
  • 字段的标签及其接受的文件类型
  • 你的目标以及字段周围的页面内容

它匹配的是文档的用途,而不只是文件类型。为了帮助它:

  • 使用描述性的名称。 Maria_Garcia_CV_2026.pdf 胜过 scan_0412.pdf。
  • 添加描述,在名称无法说明一切时:“简历,2026 年更新”“护照照片页”。
  • 在目标中说明使用哪个文件,在这一点很重要时:“附上她的简历(不是求职信)”。
  • 只传入运行需要的文件,当你有很多相似的文件时,不要用 "*"。

列出和删除文件#

cURL
# List your files, sorted by name
curl https://lovelyrouter.com/v1/browser/files -H "Authorization: Bearer $LOVELY_API_KEY"

# Delete by name or id
curl -X DELETE "https://lovelyrouter.com/v1/browser/files/Maria_Garcia_CV_2026.pdf" -H "Authorization: Bearer $LOVELY_API_KEY"

列表返回 {"object": "list", "data": [...]},每个文件对应一个文件对象。last_used_at 显示运行最后一次附加它的时间。删除成功会返回 {"deleted": "<name or id>"},否则返回 404,错误为 No such file。你也可以在控制台的 密钥与文件 中上传和删除文件。

错误#

状态码错误信息原因
400File names are 1-128 chars: letters, digits, space . _ - ( ) + ,名称包含其他字符或过长。
400Empty file请求体没有任何字节。
400Send multipart/form-data with a "file" field (and optional "description", "name")multipart 表单中没有 file 字段。
409file limit reached (100); delete some first你已经有 100 个文件。替换已有名称的文件仍然可行。
413Files are limited to 10 MB文件超过 10 MB。