Lovely Router文档
获取密钥
数据工具

找到合适的工具

浏览目录、按关键词搜索、描述任务以获得按顺序排列且附带费用的方案,并在运行前读取工具的输入结构。

目录端点是公开且免费的。你可以不带密钥调用它们,智能体也可以按需反复调用,直到选出合适的工具。查找工具共有四个端点:

你想要调用
查看全部工具,或某一个分类GET /v1/tools
用“tiktok comments”这样的简短查询查找工具POST /v1/tools/discover
描述整个任务,获得附带费用的方案POST /v1/tools/suggest
读取单个工具的输入结构、示例和价格GET /v1/tools/{id}

浏览目录#

GET /v1/tools 返回所有可用工具及其价格。用查询参数缩小范围:

  • category:一个分类 id,例如 reviews 或 lead-generation。参阅分类。
  • q:关键词。结果按相关度排序,最多 100 个。
  • lang:设为 zh 或 ja,返回本地化的工具名称和描述。默认为英文。
cURL
curl "https://lovelyrouter.com/v1/tools?category=reviews"

响应是一个工具对象列表(此处只保留一个):

JSON
{
  "object": "list",
  "data": [
    {
      "id": "google-maps-reviews",
      "name": "Google Maps reviews",
      "platform": "Google Maps",
      "category": "reviews",
      "description": "Reviews of a Google Maps place (by place ID or URL): text, stars, date, owner replies.",
      "price": {
        "per_call_usd": 0,
        "per_result_usd": 0.000675,
        "unit": "review",
        "label": "$0.000675 / review"
      },
      "default_results": 20,
      "max_results": 500,
      "featured": false
    }
  ]
}

price 对象是实时价格。default_results 是你没有设置 max_results 时运行使用的结果上限,max_results 则是该工具接受的最高上限。所有字段的说明见工具对象。

按关键词搜索#

POST /v1/tools/discover 接受一个简短查询,返回最匹配的工具及其相关度 score。平台名和工具名的权重高于描述,所以查询中点名某个平台时,该平台的工具会排在前面。

cURL
curl https://lovelyrouter.com/v1/tools/discover \
  -H "content-type: application/json" \
  -d '{"query": "google maps reviews", "limit": 3}'
JSON
{
  "query": "google maps reviews",
  "count": 3,
  "results": [
    {
      "id": "google-maps-reviews",
      "name": "Google Maps reviews",
      "platform": "Google Maps",
      "category": "reviews",
      "price": { "per_call_usd": 0, "per_result_usd": 0.000675, "unit": "review", "label": "$0.000675 / review" },
      "default_results": 20,
      "max_results": 500,
      "score": 0.889
    },
    {
      "id": "google-maps-places",
      "name": "Search Google Maps places",
      "platform": "Google Maps",
      "category": "search",
      "price": { "per_call_usd": 0.00075, "per_result_usd": 0.000238, "unit": "place", "label": "$0.000238 / place + $0.00075 / call" },
      "default_results": 10,
      "max_results": 200,
      "score": 0.717
    },
    {
      "id": "google-maps-leads",
      "name": "Google Maps leads with emails",
      "platform": "Google Maps",
      "category": "lead-generation",
      "price": { "per_call_usd": 0, "per_result_usd": 0.00075, "unit": "place", "label": "$0.00075 / place" },
      "default_results": 10,
      "max_results": 200,
      "score": 0.556
    }
  ]
}

limit 默认为 5,最大为 40。score 用来给结果排序,而不是绝对的衡量标准:它只在同一个查询内比较各个工具。

规划任务#

当任务需要不止一个工具,或者你不知道该用哪个时,用平实的语言描述它。POST /v1/tools/suggest 在一秒内返回按顺序排列的方案:首先运行的工具、一个可选的第二个工具,以及相近的备选工具,每一项都附带示例输入和预计费用。

cURL
curl https://lovelyrouter.com/v1/tools/suggest \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/json" \
  -d '{"task": "Find vegan restaurants in Austin and summarize what their reviews complain about"}'

响应(有删减):

JSON
{
  "task": "Find vegan restaurants in Austin and summarize what their reviews complain about",
  "source": "ai",
  "cached": false,
  "count": 2,
  "suggestions": [
    {
      "step": 1,
      "role": "primary",
      "match": 0.961,
      "id": "google-maps-places",
      "name": "Search Google Maps places",
      "price": { "per_call_usd": 0.00075, "per_result_usd": 0.000238, "unit": "place", "label": "$0.000238 / place + $0.00075 / call" },
      "input": {
        "searchTerms": ["coffee shop"],
        "location": "Austin, Texas, USA",
        "maxResults": 3,
        "language": "en"
      },
      "input_required": [],
      "max_results": 10,
      "est_cost_usd": 0.00313,
      "run": {
        "method": "POST",
        "path": "/v1/tools/google-maps-places/run",
        "body": { "input": { "searchTerms": ["coffee shop"], "location": "Austin, Texas, USA", "maxResults": 3, "language": "en" }, "max_results": 10 }
      }
    },
    {
      "step": 2,
      "role": "next",
      "match": 0.875,
      "id": "google-maps-reviews",
      "name": "Google Maps reviews",
      "price": { "per_call_usd": 0, "per_result_usd": 0.000675, "unit": "review", "label": "$0.000675 / review" },
      "input": { "placeIds": ["ChIJN1t_tDeuEmsRUsoyG83frY4"], "maxReviews": 3, "reviewsSort": "newest" },
      "input_required": [],
      "max_results": 20,
      "est_cost_usd": 0.0135,
      "run": {
        "method": "POST",
        "path": "/v1/tools/google-maps-reviews/run",
        "body": { "input": { "placeIds": ["ChIJN1t_tDeuEmsRUsoyG83frY4"], "maxReviews": 3, "reviewsSort": "newest" }, "max_results": 20 }
      }
    }
  ],
  "total_est_cost_usd": 0.01663
}

解读方案#

  • role 说明这一步在方案中的位置:primary 是首先运行的工具;next 获取任务需要的第二类数据(这里是第 1 步找到的地点的评论);alternative 是相近的备选,可以代替 primary 使用。
  • match 是规划服务对这一步的置信度,范围 0 到 1。
  • input 是工具的示例输入,并不是针对你的任务写的。 请把其中的值换成你自己的:上例中,"coffee shop" 应改为 "vegan restaurant"。input_required 列出你必须设置的字段。完整结构请调用 GET /v1/tools/{id}。
  • est_cost_usd 是这一步在所示 max_results(即工具的默认上限)下的最高费用。修改 max_results,费用会随之按比例变化。
  • total_est_cost_usd 是 primary 和 next 两步费用之和。备选工具不计入,因为你会用它们替代主工具,而不是额外再运行。
  • run 是一个现成的运行工具请求:填好输入后,把 body 发送到 path 即可。

suggestions 为空列表表示目录中没有适合该任务的工具,例如“write a poem”。如果规划服务不可用,该端点会退回到关键词匹配,并把 source 设为 keyword。相同的任务会在一天内直接从缓存返回,并带上 cached: true。

选项与限制#

请求体接受 task(必填,最多 2,000 个字符)、limit(建议数量,1 到 8,默认 5)和 lang(zh 或 ja)。

规划免费,但有频率限制:

调用方限制
带 API 密钥每个密钥每分钟 100 次请求
不带密钥每分钟 100 次请求,由所有匿名调用方共享

超出限制时,端点返回 429,并带有以秒为单位的 retry-after 请求头。带上你的密钥,即可获得独立的限额。

查看工具详情#

运行工具之前,先读取它的输入结构。GET /v1/tools/{id} 返回工具对象,外加 input_schema(input 的 JSON Schema)、可以直接使用的 example_input、以 timeout_s 表示的运行时限,以及一个现成的 run 请求。

cURL
curl https://lovelyrouter.com/v1/tools/trustpilot-reviews

响应(有删减):

JSON
{
  "id": "trustpilot-reviews",
  "name": "Trustpilot reviews",
  "platform": "Trustpilot",
  "category": "reviews",
  "description": "Trustpilot reviews of a company by domain: stars, text, date, reply.",
  "price": {
    "per_call_usd": 0.0075,
    "per_result_usd": 0.0015,
    "unit": "review",
    "label": "$0.0015 / review + $0.0075 / call"
  },
  "default_results": 20,
  "max_results": 500,
  "featured": false,
  "input_schema": {
    "type": "object",
    "properties": {
      "companyUrls": {
        "type": "array",
        "title": "Company URLs or Domains",
        "description": "Enter Trustpilot company URLs (e.g., https://www.trustpilot.com/review/example.com) or just the domain (e.g., example.com). One per line."
      },
      "maxReviewsPerCompany": {
        "type": "integer",
        "title": "Max reviews per company (reviews)",
        "description": "Maximum number of reviews to scrape per company. Set to 0 for unlimited reviews.",
        "default": 0,
        "minimum": 0
      },
      "sort": {
        "type": "string",
        "title": "Sort Order",
        "enum": ["relevance", "recency"],
        "default": "recency"
      }
    },
    "required": ["companyUrls"]
  },
  "example_input": {
    "companyUrls": ["pipedrive.com"],
    "maxReviewsPerCompany": 20
  },
  "timeout_s": 300,
  "run": {
    "method": "POST",
    "path": "/v1/tools/trustpilot-reviews/run",
    "body": { "input": { "companyUrls": ["pipedrive.com"], "maxReviewsPerCompany": 20 }, "max_results": 20 }
  }
}

不同工具的字段名及其含义各不相同,所以请始终根据 input_schema 构造 input。你不需要通过设置工具自带的数量字段(这里是 maxReviewsPerCompany)来控制费用:无论如何,max_results 都会给运行设定上限。工具页面为每个工具展示同样的结构,登录后还可以直接在那里试用工具。

未知或已下线的工具 id 返回 404。

本地化名称和描述#

在任意目录请求中加上 lang=zh 或 lang=ja:GET 请求作为查询参数,POST 请求放在请求体的 "lang" 中。返回的工具名称和描述即为译文。id、价格和输入结构保持不变。

cURL
curl "https://lovelyrouter.com/v1/tools/google-maps-reviews?lang=ja"

后续步骤#