交给你的 AI 智能体
把这段提示词复制到 Claude Code、Cursor、Codex 或任何编程智能体中。它会告诉智能体文档在哪里,以及如何使用你的 API 密钥。
Add web search and page reading to this project with the Lovely Router web search API.
- Docs (read first): https://lovelyrouter.com/docs/tools.md and https://lovelyrouter.com/docs/tools/run.md
- Search: POST https://lovelyrouter.com/v1/tools/web-search/run. Read a page as clean text/Markdown: POST https://lovelyrouter.com/v1/tools/web-fetch/run. Get each tool's input fields first with GET https://lovelyrouter.com/v1/tools/web-search and GET https://lovelyrouter.com/v1/tools/web-fetch (public, no key needed).
- Request body: `{"input": {...}}`. A 202 means the run is still going: poll the `poll` path until `status` is final, then read `items`.
- If you support MCP, you can instead connect the server https://lovelyrouter.com/mcp (Streamable HTTP, same key; https://lovelyrouter.com/docs/tools/mcp.md) and use suggest_tools, get_tool and run_tool.
- 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: <describe what you want to build or get>工作原理
获取密钥
搜索网页
在
input中发送查询,并可选地设置count(1 到 50 条结果)。价格按每次搜索计算,count不会改变价格。Shellcurl https://lovelyrouter.com/v1/tools/web-search/run \ -H "Authorization: Bearer $LOVELY_API_KEY" \ -H "content-type: application/json" \ -d '{ "input": {"query": "electric car prices site:reuters.com OR site:bloomberg.com after:2026", "count": 10}, "max_results": 1 }'阅读值得读的页面
把一个 URL 传给
web-fetch,即可以 Markdown 格式拿到它的标题和正文,不含菜单和广告。cURLcurl https://lovelyrouter.com/v1/tools/web-fetch/run \ -H "Authorization: Bearer $LOVELY_API_KEY" \ -H "content-type: application/json" \ -d '{"input": {"url": "https://en.wikipedia.org/wiki/Web_search_engine"}, "max_results": 1}'
默认情况下,每个请求最多等待运行 60 秒(wait 最高可设为 300)。已完成的运行返回 200,带有 charge_usd 以及 items 中的结果;耗时更长的运行返回 202 和一个用于轮询的路径。两种情况都在运行工具中有说明。
搜索工具
搜索网页:最多 50 条结果,包含标题、URL、日期、站点、简短摘要和供模型阅读的长摘要(需要时可附带网页正文)。支持运算符:site:、-site:、"精确短语"、-词、lang:、after:、before:。
把任意公开网页读取为干净的 Markdown:标题和正文,不含导航和广告。适用于已知 URL 的单个页面。
Google 搜索结果页:自然结果、广告、“相关问题”和相关搜索。一条结果 = 一个结果页(约 10 条自然链接)。
Google 新闻中某个搜索的新闻文章(支持运算符:"精确短语"、OR、-排除词、site:、intitle:),可限定时间范围:标题、来源、日期及发布网站上的文章链接。
最多返回 50 条结果,包含标题、URL、日期、站点、简短摘录,以及一段写给模型的长摘要。设置 need_content 可同时获取每个页面的正文,传入用户的原始 question 可以让结果排序更准确。
适用于你已经知道 URL 的页面:以 Markdown 返回任意公开网页的标题和正文。
返回 Google 自己的搜索结果页:排名、标题、URL、摘录、日期、附加链接和相关搜索,可按 country 和界面语言 hl 指定,并通过 tbs 设置时间筛选。每个约含十条链接的结果页算作一条计费结果。
返回文章的标题、来源、日期和发布方网站上的链接,可限定在某个时间窗口内,例如最近 1d,或一个 dateFrom / dateTo 区间。
返回某个关键词随时间和按地区的热度,或某个国家的热门搜索。
搜索运算符
web-search 会识别 query(1 到 128 个字符)中的这些运算符:
| 运算符 | 示例 | 效果 |
|---|---|---|
site: | site:a.com OR site:b.com | 只搜索这些站点 |
-site: | -site:example.com | 排除某个站点 |
"…" | "prompt caching" | 精确短语 |
-word, -"…" | -jobs | 排除某个词或短语 |
lang: | lang:en 或 lang:zh,en | 只返回这些语言的结果 |
after:, before: | after:2026-01-01, before:2026-06 | 在某个时间范围内发布(年份或日期) |
google-news 支持 "精确短语"、OR、-word、site: 和 intitle:;google-search 接受的运算符与你在 Google 中输入的一样。
通过 MCP 在智能体中使用
连接 MCP 服务器后,你的智能体就会获得 web_search 和 web_fetch 两个工具,与数据工具目录中的其他工具并列。服务器会告诉智能体:凡是需要查找或阅读的内容都用它们,浏览器智能体只留给需要点击操作的页面。结果以简短的编号列表返回,web_fetch 会把长页面按约 12,000 个字符分段返回,继续阅读免费。
claude mcp add --transport http lovely-tools https://lovelyrouter.com/mcp \
--header "Authorization: Bearer $LOVELY_API_KEY"然后在 Claude Code 中提问:“在新闻网站上搜索本周关于固态电池的公告,阅读最相关的三篇文章,总结有哪些变化,并附上链接。” Cursor、Claude Desktop 和其他客户端的配置方法见 MCP 服务器。
常见用法
用 web-search 加上 after:2026-10-01 和一组可信来源的 site:,然后用 web-fetch 读取排名前三的结果。
在查询中加上 lang:zh,en,一次搜索就能同时拿到中文和英文来源。
用你的 keyword 和 country: "US" 运行 google-search,持续记录每条结果的排名。
用 google-news 搜索加引号的公司名,并设置 openEndedDateRange: "1d"。
以 keyword 模式运行 google-trends,设置 predefinedTimeframe: "today 12-m" 和一个 geo 国家。
费用说明
web-search 按每次搜索计费,$0.0009,无论你要 1 条还是 50 条结果;没有结果的搜索不收费。web-fetch 按每个页面计费,价格相同;无法读取的页面不收费。Google 搜索按结果页计费,Google 新闻按文章计费,Google 趋势按调用计费,实时价格见上方卡片。
每次运行都会先从你的预付费余额中预留其最高费用,再按实际返回的内容结算,因此运行开始前你就知道它最多花多少钱。失败的运行只为已交付的结果付费。没有订阅;所有工具和模型的价格见价格页。
常见问题
一次网页搜索多少钱?+
每次搜索 $0.0009,count 从 1 到 50 条结果都是同一价格。什么也没搜到的搜索不收费。
web-search 和 google-search 有什么区别?+
web-search 返回附带写给模型的摘要的结果,并支持 lang:、after: 和 before:。google-search 返回 Google 自己的搜索结果页,包含排名、附加链接和相关搜索,适合做排名跟踪。
能获取每个页面的全文吗?+
可以。在 web-search 上设置 need_content 即可包含每个页面的正文,也可以把 URL 传给 web-fetch,以 Markdown 读取单个页面。
能在 Claude Code 和 Cursor 中使用吗?+
可以。用一条命令或一项配置添加 MCP 服务器,智能体就会获得 web_search 和 web_fetch 两个工具,费用从同一余额中扣除。
能读取需要登录的页面吗?+
不能。web-fetch 只读取公开页面。需要登录、填写表单或多次点击的页面,请使用浏览器智能体。
最多能同时进行多少次搜索?+
每个账户最多可以同时有 10 个运行在进行中,浏览器智能体的运行也计算在内。超过上限的运行会收到 429,等其他运行结束后再重新发起即可。