有些网页上的工作没有 API 可用:供应商门户、询价表单、求职申请、需要登录的账户页面。浏览器智能体把这类网页表单自动化交给 AI,只需一次 API 调用就能完成。你用平实的语言描述任务,并给出一个起始 URL。AI 智能体会在真实的 Chromium 浏览器中逐步完成:填写字段,用它永远看不到的密钥登录,附上你的文件,在提交前等待你的确认,最后以文本和 JSON 返回结果。
交给你的 AI 智能体
把这段提示词复制到 Claude Code、Cursor、Codex 或任何编程智能体中。它会告诉智能体文档在哪里,以及如何使用你的 API 密钥。
Automate a web form or multi-step web task for me with the Lovely Router browser agent: a real browser that fills forms, signs in (including 2FA), attaches files and asks before it submits.
- Docs (read first): https://lovelyrouter.com/docs/browser-agent.md and https://lovelyrouter.com/docs/browser-agent/logins.md and https://lovelyrouter.com/docs/browser-agent/human-in-the-loop.md
- Start: POST https://lovelyrouter.com/v1/browser/runs with `{"goal": "...", "start_url": "...", "approve": "submit", "output_schema": {...}}`. Put every value the form needs in the goal. Poll the `poll` path; when it waits (`needs`), show me the fields and only reply `{"approve": true}` at .../reply after I say so.
- Never put passwords or codes in the goal: store them with PUT https://lovelyrouter.com/v1/browser/vault/<name> (`value`, `kind`, `origins`) and pass the names in `secrets`.
- Billed per step. Use it only on accounts I own or may use.
- Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys.
- Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large.
- Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt.
My task: <the site, what to fill in or do, and what proves it worked>工作原理
描述任务
像给一位细心的助理交代工作那样写下目标:写清表单需要的每一个值,以及怎样算成功("告诉我确认编号")。如果你知道表单的 URL,就直接从表单页面开始。
智能体填写表单
每一步,智能体都会读取页面并执行一个操作:点击、输入、选择选项、上传文件或填入已保存的密钥。在点击提交表单的按钮之前,它会对照你的目标逐一检查每个字段,并修正不符的值。
你确认,它提交
默认情况下,智能体会在购买、预订、发送消息、删除和提交申请之前暂停,并把表单中的值展示给你。你回复确认后,运行结束并返回
answer;如果你要求了结构,还会按你的结构返回data。
一次请求填写并提交表单
curl https://lovelyrouter.com/v1/browser/runs \
-H "Authorization: Bearer $LOVELY_API_KEY" \
-H "content-type: application/json" \
-d '{
"goal": "Request a quote for 500 blue 750 ml water bottles with our logo, delivered to 12 Main St, Springfield, IL 62701 by December 1, 2026. Contact: Ada Lovelace, ada@example.com. Submit the form and tell me the quote reference.",
"start_url": "https://supplier.example.com/quote",
"approve": "submit",
"output_schema": {"quote_reference": "string", "confirmation_message": "string"},
"webhook": "https://api.example.com/hooks/browser"
}'请求会立即返回 202,智能体在后台工作。设置 "approve": "submit" 后,它会在提交按钮前停下,你的 webhook 会收到一个已签名的 run.waiting 事件,其中的 needs 包含给人看的 prompt、fields 中的表单值、action 中的按钮文字以及一张截图。确认它:
curl https://lovelyrouter.com/v1/browser/runs/brun_5b7d9f1a3c5e7a9b1d3f5a7c/reply \
-H "Authorization: Bearer $LOVELY_API_KEY" \
-H "content-type: application/json" \
-d '{"approve": true}'智能体随即点击按钮并完成任务;run.finished 事件会带着 answer 和 data 中的 JSON 到达。如果你改为回复 {"approve": false, "reason": "Wrong address"},智能体就不会提交:它会读取你给出的原因,换一种方式尝试,或者报告无法完成的原因。
登录与两步验证码
用 PUT /v1/browser/vault/{name} 把每个凭据保存一次:包括它的 value、kind(password、username、text 或 totp),以及允许输入它的 origins。在运行的 secrets 中传入这些名称。模型只能看到 portal_password 这样的名称;值只会在你允许的网站上输入,因此仿冒的登录页面拿不到它。
把 TOTP 种子保存为 totp 类型的密钥,智能体就会输入当前的 6 位验证码。
智能体会暂停并提出问题,你回复 {"secret": "481923"}。它会输入验证码,但看不到验证码本身。
在登录运行中加上 save_profile,之后的运行用 profile 启动,即可跳过登录。
对只应在一次运行中存在的凭据,传入 ephemeral_secrets;运行结束时它会被删除。
实用配方
用 PUT /v1/browser/files/{name} 上传简历和求职信,把两者都传入 files,并在目标中说明哪个文件放在哪里。智能体会根据文档的用途来匹配每个上传字段,而不只是看文件类型。
设置一个 webhook,把 run.waiting 确认请求转发到团队的聊天工具,再把他们的答复发送到该运行的 reply 路径。
从已保存的 profile 启动,同时传入 secrets,以便会话过期时智能体能重新登录,再通过 output_schema 获取最新的发票金额。
对于你放心让它自行提交的表单,比如在内部工具中登记工时,设置 "human": false 和 "approve": "none"。这样运行就不会为等待时间预留任何费用。
想观看运行过程,加上 "stream": true, "screen": true,即可实时获取每一步和浏览器画面。页面出现 CAPTCHA 时,智能体会给你一个 Live View 链接;你完成验证后回复 {"done": true},它就会继续。只在你拥有或获准使用的账户上使用智能体;详情见可接受使用政策。
常见问题
AI 能在需要两步验证登录的页面上填写表单吗?+
可以。把密码和 TOTP 种子保存为保险库密钥,智能体就会登录并输入当前的 6 位验证码。对于通过短信或邮件发送的验证码,它会暂停,由你回复验证码。
这和传统的 RPA 有什么不同?+
你不需要录制流程或编写选择器。用平实的语言描述任务并给出起始 URL,AI 智能体会在真实的浏览器中自己决定每一步:填写字段、登录、附上文件,并在提交前等待你的确认。
模型能看到我的密码吗?+
看不到。智能体使用的是密钥名称,每个值只有在输入到你允许的网站上的匹配字段时才会被解密。任何长度在六个字符及以上的密钥值,都会从页面文本、答案、数据和步骤记录中清除。
网站出现 CAPTCHA 时会怎样?+
智能体无法破解 CAPTCHA。它会通过一个有效期一小时的 Live View 链接把浏览器交给人来处理,等对方回复已完成后再继续。
能让它在提交前等待我的确认吗?+
可以。approve 的默认值为 "risky",它会在购买、下单、预订、发送消息、删除和提交申请之前暂停。把 approve 设为 "submit" 会在每次提交前暂停,设为 "none" 则让它自行提交。
Claude Code 或其他智能体能用它来填写表单吗?+
可以。MCP 服务器以 browser_run、browser_status、browser_reply 和 browser_takeover 的形式提供浏览器智能体。智能体传递的是保险库密钥的名称,而不是值本身。