# Google Custom Search API alternative：停服迁移实测

> Google Custom Search API 2027-01-01 停服：参数逐项对照、59 次真调，每千次 $5 降到 $0.694，空结果不扣钱。

- Canonical page: https://everyinfra.com/blog/google-custom-search-api-alternative
- Published: 2026-11-08T01:54:00+08:00 · Fact-checked: 2026-11-08T01:00:00+08:00

Google 的 Custom Search JSON API 已经不收新客户，老客户的调用到 [2027 年 1 月 1 日](https://developers.google.com/custom-search/v1/overview)全部停止。我们把它的参数逐个搬到 EveryInfra 上真调，`web` 工具每 1,000 次 $0.694，约为 Google 现价 $5 的 14%，每天用满 1 万次时月账从 $1,485 降到 $208.20。迁移时最要先处理的是两件事：`site` 参数 3 次里有 2 次返回 0 条，要改成在查询词里写 `site:`；照搬 Google 的 `start`、`cx` 会直接返回 422，而不是像 Google 那样被悄悄忽略。

> **本文要点**
>
> - Google Custom Search JSON API 已不收新客户，2027 年 1 月 1 日停服；现价每 1,000 次 $5，每天 100 次免费，每天最多 1 万次，单个查询最多 100 条结果。
> - EveryInfra `web` 工具每 1,000 次 $0.694（目录价与实测 `charged_usd` 一致），`bing/search` $0.556，`web/search` $1.389；每天 1 万次时月账 $208.20，Google 是 $1,485。每天 100 次以内 Google 免费、我们每月约 $2.08，这一档 Google 更便宜。
> - 本文 59 次真调里 48 次扣费、11 次没扣钱：401、3 次参数错（422）、空结果和服务暂时不可用都是 $0，合计花费 $0.039858。
> - q、num、start、gl、dateRestrict、引号和减号都有对应写法；hl、safe、searchType=image 没有一对一的参数；`site` 参数不稳，限定站点写进查询词更稳。
> - 照搬 Google 的 `start`、`cx` 会被 422 拦下并列出可用参数；从 Bing 搬来的 `count` 要改成 `limit`，以响应里的 `allowed` 列表为准。

这篇是迁移指南，写给手里还在调 `customsearch/v1` 或者以前用 Bing Web Search API 的开发者，回答的是同一个问题（英文里常搜成 google custom search api alternative 或 bing search api alternative）：截止日之前搬到哪里、参数怎么改、每月要花多少钱。对方产品一侧，我们只读公开的官方文档、定价页和论坛原帖，2026 年 11 月 8 日 00:14–00:40（新加坡时间）逐页打开存档，没有注册、没有调用别家的接口；我们自己这一侧全部是同一天的真调，每个数字都能回到原始返回。站内已经有一篇按 agent 需求比六家搜索接口的[选型文](/blog/best-web-search-api-for-ai-agents)，另有一篇按任务阶段讲[什么时候用哪个搜索工具](/build/agent-search-tool-selection)；本篇不重复那两篇，只讲「从 Google 和 Bing 搬出来」这一件事，还没决定搬不搬的先读本篇。

![示意插图：左边一块旧的接线面板上有很多圆孔，彩色线缆从这里连到右边一块更小的新面板。大多数线缆直接插进新面板对应的孔；两根线缆末端接了转接头，插头形状变了；还有一根线缆垂在地上，没有可插的孔；新面板上有一个孔亮着青绿色的圈。](https://everyinfra.com/articles/google-custom-search-api-alternative/img-explain.webp)

迁移就是换插头：大多数参数直接对上，少数要换写法，个别参数在新接口里没有对应。

## 先看结论：按用法选 Google Custom Search API 的替代品

先把结论放在前面。用 Custom Search JSON API 的人大致分三种：在自己网站上做站内搜索的、拿它搜全网做产品或数据的、给 AI agent 当搜索工具的。三种人的去处不一样，Google 自己给的路只覆盖第一种；下面这张表按用法给出可去的地方、每千次价格和要改的东西，价格都是 2026 年 11 月 8 日读的公开价或我们的目录价。

| 你现在的用法 | 可以迁到哪 | 每 1,000 次 | 要改什么 |
| --- | --- | --- | --- |
| 自己网站的站内搜索，50 个域名以内，要搜索框 | Google Programmable Search Element（免费版带 Google 广告） | $0 | 换成嵌入代码，不再走 JSON |
| 自己网站的站内搜索，要 JSON、要控制排序 | Google Agent Search 企业版（原 Vertex AI Search） | $4.00 | 建数据存储、建应用、换认证，14 步 |
| 搜全网，做产品、监控、数据 | EveryInfra `web` 工具 | $0.694 | 参数改名，`start` 换成 `page` |
| 搜全网，要 Bing 的结果页 | EveryInfra `bing/search` | $0.556 | `count`/`offset` 不能用，每次只回第一页 |
| 搜全网，要带国家和语言偏好 | EveryInfra `web/search` | $1.389 | `gl`→`country`，`hl`→`language` |
| 搜全网，要完整结果页（广告、知识面板等） | SerpAPI、Serper、Bright Data | $0.30–$25.00 | 换成对方的参数和返回结构 |
| 给 agent 用，要正文片段 | Tavily、Firecrawl，或我们的 `web` 加 `read` | $1.50–$8.00 | 改成工具调用 |

这张表里有一个容易漏看的地方：Google 推荐的 Agent Search 只覆盖「最多 50 个域名」的站内搜索。Google 在 [2026 年 1 月 20 日的博客](https://programmablesearchengine.googleblog.com/2026/01/updates-to-our-web-search-products.html)里写得很清楚，搜全网的用户要「联系我们」询问另一套全网搜索方案，没有公开价格。所以如果你拿 Custom Search JSON API 搜全网，Google 自己没有给你一个能马上开通的替代品，只能看第三方。

## 停服时间线：Google 和 Bing 各关了什么

两家大搜索引擎的公开搜索 API 在一年多里先后关门。微软在[生命周期公告](https://learn.microsoft.com/en-us/lifecycle/announcements/bing-search-api-retirement)里写明 Bing Search APIs 于 2025 年 8 月 11 日退役，现有实例全部下线、不再接受新注册，建议客户改用 Azure AI Agents 里的 Grounding with Bing Search。Google 这边分了几步：网站受限版的 [Site Restricted JSON API](https://developers.google.com/custom-search/v1/site_restricted_api) 在 2025 年 1 月 8 日停止服务；2026 年 1 月 20 日，Programmable Search Engine 团队宣布新建的搜索引擎一律只能用「Sites to search」，最多 50 个域名，老引擎的「Search the entire web」开关保留到 2027 年 1 月 1 日；同一天，Custom Search JSON API 对新客户关闭，老客户也要在 2027 年 1 月 1 日前搬走。

下面这张截图是 Google 开发者文档里的定价段落原文，我们在 2026 年 11 月 8 日 00:2x（新加坡时间）打开，页面底部写着最后更新于 2026 年 2 月 18 日。青绿框里的三句话就是本文所有价格计算的起点：只对老客户有效、每天 100 次免费、超出部分每 1,000 次 $5、每天最多 1 万次。

![网页截图：Google for Developers 的 Custom Search JSON API 概览页「Pricing」一节，青绿色框标出整段原文：以下价格只适用于现有客户，直到 2027 年 1 月 1 日停服；该 API 不再向新客户开放；每天 100 次免费查询；超出部分每 1,000 次 $5，每天最多 1 万次。](https://everyinfra.com/articles/google-custom-search-api-alternative/img-shot-google-pricing.webp)

Google 原文：老客户的价格只到 2027 年 1 月 1 日。2026-11-08 截图。 [Google for Developers 截图](https://developers.google.com/custom-search/v1/overview)

| 日期 | 发生了什么 | 原文 |
| --- | --- | --- |
| 2025-01-08 | Google 的 Custom Search Site Restricted JSON API 停止服务 | [developers.google.com](https://developers.google.com/custom-search/v1/site_restricted_api) |
| 2025-08-11 | Bing Search APIs 退役，现有实例下线 | [learn.microsoft.com](https://learn.microsoft.com/en-us/lifecycle/announcements/bing-search-api-retirement) |
| 2026-01-20 | 新建引擎只能限定 50 个域名；Custom Search JSON API 不收新客户 | [Programmable Search Engine 博客](https://programmablesearchengine.googleblog.com/2026/01/updates-to-our-web-search-products.html) |
| 2026 年 4 月 | Vertex AI Search 改名 Agent Search（Gemini Enterprise Agent Platform 下） | [Google Cloud 改名对照表](https://docs.cloud.google.com/gemini-enterprise-agent-platform/vertex-ai-name-changes) |
| 2026-09-09 前后 | Google 发布只给合作方的 Web Search Service API 文档，随后撤下 | [Search Engine Journal 报道](https://www.searchenginejournal.com/google-documents-partner-only-api-for-full-web-search-results/589194/) |
| 2026-10-16 | Google 社区经理在帮助论坛重贴停服说明，再次写明 2027 年 1 月 1 日截止 | [Programmable Search 社区](https://support.google.com/programmable-search/thread/473199482/updates-to-our-web-search-products-programmable-search-engine-capabilities?hl=en) |
| 2027-01-01 | Custom Search JSON API 停服；老引擎失去「Search the entire web」 | [developers.google.com](https://developers.google.com/custom-search/v1/overview) |

这条时间线说明了一件事：截止日不是 Google 第一次收缩搜索接口，表里 2025 年 1 月停掉的 Site Restricted JSON API 就是上一步。对开发者来说，这意味着即使搬到 Google 自己的 Agent Search，也要预留下一次变化的余地；我们建议把搜索调用包在一层自己的函数里，换供应商时只改这一层。

## Google 还有没有搜索 API：2026 年 11 月还剩哪些官方入口

论坛里最常见的一个问题是「Google 还有没有搜索 API」。截至 2026 年 11 月 8 日，答案是「对普通开发者，没有能自助开通的全网搜索 API」。我们逐个打开了 Google 和微软的官方页面，结果列在下面。

| 官方入口 | 能搜什么 | 谁能用 | 价格 | 2026-11-08 状态 |
| --- | --- | --- | --- | --- |
| Custom Search JSON API | 全网或指定站点 | 只剩老客户 | $5/千次，100 次/天免费 | 2027-01-01 停服 |
| Programmable Search Element | 最多 50 个域名 | 任何人 | 免费，带广告 | 继续提供，是嵌入式搜索框 |
| Agent Search 企业版 | 最多 50 个域名的网站搜索 | Google Cloud 客户 | $4.00/千次，每月 1 万次免费试用 | 继续提供，要建数据存储 |
| 全网搜索方案（表单申请） | 全网 | 要申请 | 未公开 | 只有一张兴趣表单 |
| Web Search Service API | 全网 | 只给签了协议的合作方 | 未公开 | 文档页面已 404 |
| Grounding with Bing Search | 全网 | Azure 付费订阅 | $14/千次 | 只能在 Azure AI Foundry 里用，原始结果拿不到 |

最后两行值得多说一句。Search Engine Journal 在 [2026 年 9 月 11 日](https://www.searchenginejournal.com/google-documents-partner-only-api-for-full-web-search-results/589194/)报道，Google 公开了 Web Search Service API 的文档，每个请求都要带合作方协议对应的 client ID 和最终用户的 IP 地址；Search Engine Roundtable 在 [9 月 28 日](https://www.seroundtable.com/google-web-search-service-api-documentation-removed-42168.html)报道文档已被撤下。我们在 11 月 8 日用 curl 请求原来的文档地址，返回的是 404，所以它目前不是一个可以写进迁移计划的选项。微软那边，[Grounding with Bing 的定价页](https://www.microsoft.com/en-us/bing/apis/grounding-pricing)写明每 1,000 次交易 $14，同时写明输出「不能直接在其他应用或程序中使用」；它的[使用文档](https://learn.microsoft.com/en-us/azure/ai-services/agents/how-to/tools/bing-grounding?view=azure-python-preview&tabs=python&pivots=overview)也说开发者和最终用户都拿不到原始返回内容，只能拿到模型生成的回答和引用。这和 Bing Web Search API 返回一页 JSON 结果是两种东西，做数据的人用不上。

## Google 搜索 API 价格：Google 现价和替代品每千次多少钱

价格是迁移时最先要算的。下面这张表把 Google 现价、Google 和微软自己的替代品，以及五家第三方搜索接口放在同一个单位上：每 1,000 次搜索、每次 10 条结果。对方的价格来自各家定价页原文，读取时间是 2026 年 11 月 8 日 00:16–00:20（新加坡时间）；按 credit 计价的我们按对方文档里「一次搜索扣几个 credit」折算，算术写在表后。我们自己的价格来自[搜索工具目录](https://api.everyinfra.com/api/v1/search/tools)和[数据能力目录](https://api.everyinfra.com/api/v1/social/catalog)的 `price_usd`，并和真调响应里的 `billing.charged_usd` 逐次核对过。

| 服务 | 入门付费档 | 页面最低一档 | 免费额度 | 原文 |
| --- | --- | --- | --- | --- |
| Google Custom Search JSON API | $5.00 | $5.00 | 100 次/天 | [overview](https://developers.google.com/custom-search/v1/overview) |
| Google Agent Search 企业版 | $4.00 | $4.00 | 1 万次/月试用 | [Agent Search 定价](https://cloud.google.com/generative-ai-app-builder/pricing) |
| Grounding with Bing Search | $14.00 | $14.00 | 无 | [Bing 定价页](https://www.microsoft.com/en-us/bing/apis/grounding-pricing) |
| SerpAPI | $25.00 | $3.75 | 250 次/月 | [serpapi.com/pricing](https://serpapi.com/pricing) |
| Serper | $1.00 | $0.30 | 2,500 次 | [serper.dev](https://serper.dev/) |
| Tavily | $8.00 | $5.00 | 1,000 credits/月 | [Tavily 文档](https://docs.tavily.com/documentation/api-credits) |
| Firecrawl | $7.60 | $1.50 | 1,000 credits/月 | [firecrawl.dev/pricing](https://www.firecrawl.dev/pricing) |
| Bright Data SERP API | $1.50 | $1.30 | 5,000 次/月 | [brightdata.com](https://brightdata.com/pricing/serp) |
| EveryInfra `web` | $0.694 | $0.694 | $1 试用额度 | [目录](https://api.everyinfra.com/api/v1/search/tools) |
| EveryInfra `bing/search` | $0.556 | $0.556 | 同上 | [目录](https://api.everyinfra.com/api/v1/social/catalog) |
| EveryInfra `web/search` | $1.389 | $1.389 | 同上 | [目录](https://api.everyinfra.com/api/v1/social/catalog) |

几处折算要交代清楚。SerpAPI 的 Starter 档是每月 $25 买 1,000 次，所以入门价就是每千次 $25；最低一档 Cloud 1M 是每月 $3,750 买 100 万次，折合 $3.75。Serper 的 Starter 是 $50 买 5 万个 credits，页面自己写着「$1.00/1k」，最大一档 Ultimate 写着「$0.30/1k」，所有档的 credits 都是 6 个月有效。Tavily 文档写基础搜索每次 1 个 credit，按量价 $0.008，月套餐最低 $0.005，所以是 $8.00 和 $5.00。Firecrawl 的[计费文档](https://docs.firecrawl.dev/billing)写搜索「每 10 条结果 2 credits」，Hobby 档每月 $19 买 5,000 credits，折合 2,500 次搜索，就是每千次 $7.60；Scale 档月付 $749 买 100 万 credits、50 万次搜索，折合 $1.50。Bright Data 的 SERP API 按量 $1.5/1K，Scale 档每月 $499 含 38 万次、超出 $1.3/1K。

![横向条形图，对数刻度，每格 10 倍：每 1,000 次搜索的入门付费价。从高到低是 SerpAPI $25.00、Grounding with Bing Search $14.00、Tavily $8.00、Firecrawl $7.60、Google Custom Search JSON API $5.00、Google Agent Search 企业版 $4.00、Bright Data $1.50、EveryInfra web/search $1.389、Serper $1.00、EveryInfra web $0.694、EveryInfra bing/search $0.556。EveryInfra web 一根用青绿色标出。](https://everyinfra.com/articles/google-custom-search-api-alternative/fig-03-price-per-1k-bar.zh.light.svg)

这张图只说一件事：在「一次搜索、一页 10 条」这个最基本的单位上，Google 的 $5 处在中间偏上的位置，比它便宜的选择不少。但图上的数是入门档，不是全部：Serper 在大用量时每千次能到 $0.30，比我们的 $0.694 还低；SerpAPI 的 $25 买的是包含广告、知识面板、地图包在内的整页结构化结果，和只回标题、链接、摘要的接口不是一样的东西。选型时要先看你到底要哪些字段，再看价格。

## 每月账单：100 次/天免费额度和 1 万次/天上限怎么算

Google 的计价有两个边界：每天 100 次免费，每天最多 1 万次。这两个边界让「每千次 $5」在不同用量下的实际月账差别很大。我们按 30 天一个月，把四个日用量档放在一起算：

| 每天查询次数 | 每月次数 | Google CSE 月账 | Agent Search 企业版 | EveryInfra `web` | EveryInfra `bing/search` |
| --- | --- | --- | --- | --- | --- |
| 100 | 3,000 | $0（全在免费额度内） | $0（试用额度内） | $2.08 | $1.67 |
| 1,000 | 30,000 | $135.00 | $80.00 | $20.82 | $16.68 |
| 3,000 | 90,000 | $435.00 | $320.00 | $62.46 | $50.04 |
| 10,000 | 300,000 | $1,485.00 | $1,160.00 | $208.20 | $166.80 |
| 30,000 | 900,000 | 超出每天上限，不能用 | $3,560.00 | $624.60 | $500.40 |

算法是这样的：Google 的月账 =（日用量 − 100）× 30 × $0.005，日用量超过 1 万次就不能用；Agent Search 企业版 =（月用量 − 10,000）× $0.004，而且只能搜 50 个域名以内的网站，不是全网；我们的两个数是月用量乘目录价，没有免费额度可扣（新账户有 $1 试用额度，24 小时内有效，不按月发）。

![折线图，纵轴为对数刻度：按每天查询次数 100、1,000、3,000、10,000、30,000 算的月账。Google Custom Search JSON API 依次是 $0、$135、$435、$1,485，日用量 3 万次时不能用；Agent Search 企业版 $0、$80、$320、$1,160、$3,560；EveryInfra web 依次是 $2.08、$20.82、$62.46、$208.20、$624.60，青绿色；EveryInfra bing/search 依次是 $1.67、$16.68、$50.04、$166.80、$500.40。](https://everyinfra.com/articles/google-custom-search-api-alternative/fig-04-monthly-cost-line.zh.light.svg)

从这张图可以读出三点。第一，每天 100 次以内 Google 是免费的，我们每月要 $2.08，这一档 Google 更便宜，直到停服那天；如果你的用量就在这个范围，不急着搬，但要在 12 月底前测好新接口。第二，一旦每天超过几百次，差距按 7.2 倍放大（$5 ÷ $0.694），每天 1 万次时每月差 $1,276.80。第三，Google 的每天 1 万次是硬上限，想更多只能开多个项目；我们没有每日上限，限制在每分钟：[价格页](/pricing)写明每个账户默认每分钟 60 次（同一账户下的所有 Key 共用），相当于每天最多 86,400 次；要更高可以买 30 天的速率包，或者累计充值达到更高一档。

## 参数对照：Custom Search JSON API 的参数在新接口里怎么写

迁移最费工夫的是参数。Google 的 [cse.list 参考](https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list)列了 30 多个查询参数，我们把真正常用的 22 个逐个对到 EveryInfra 的三个入口上。「验证」一列写的是本文哪一次真调测过；没测过的写「未测」，按目录描述写。

| Google 参数 | 作用（Google 原文） | `web` 工具 | `web/search` | `bing/search` | 验证 |
| --- | --- | --- | --- | --- | --- |
| `key` | API Key，放在 URL 里 | `Authorization: Bearer` 头 | 同左 | 同左 | 401 实测 |
| `cx` | 搜索引擎 ID | 没有，传了返回 422 | 没有 | 没有 | 422 实测 |
| `q` | 查询词 | `q` | `keyword` | `keyword` | 实测 |
| `num` | 每次 1–10 条 | `num`，1–10 | 固定最多 10 条 | `limit` | 实测 |
| `start` | 第几条开始，start+num ≤ 100 | `page`（从 1 开始） | 没有 | 没有，只回第一页 | 422 与翻页实测 |
| `gl` | 用户所在国家，提升该国结果 | `location`（国家名或两位代码） | `country` | `country` | 实测 |
| `hl` | 界面语言 | 没有 | `language` | `language`（要和 country 一起给） | 实测 |
| `cr` | 只要某国来源的文档 | 没有，用 `location` 近似 | 没有 | 没有 | 未测 |
| `lr` | 只要某种语言的文档 | 没有 | `language` 近似 | `language` 近似 | 未测 |
| `siteSearch` | 包含或排除某站点 | `site`，或在 `q` 里写 `site:` | 在 `keyword` 里写 `site:` | 在 `keyword` 里写 `site:` | 实测 |
| `siteSearchFilter` | i 包含 / e 排除 | 在 `q` 里写 `-site:` | 同左 | 同左 | 未测 |
| `dateRestrict` | 最近 N 天/周/月/年 | `after`、`before`（日期） | 没有 | 没有 | 实测 |
| `sort=date` | 按日期排序 | 没有 | 没有 | 没有 | — |
| `exactTerms` | 必须包含的短语 | 在 `q` 里加引号 | 同左 | 同左 | 实测 |
| `excludeTerms` | 不能出现的词 | 在 `q` 里写 `-词` | 同左 | 同左 | 实测 |
| `orTerms` | 至少包含其一 | 在 `q` 里写 `OR` | 同左 | 同左 | 未测 |
| `fileType` | 文件扩展名 | 在 `q` 里写 `filetype:pdf` | 同左 | 同左 | 实测 |
| `safe` | SafeSearch 开关 | 没有 | 没有 | 没有 | — |
| `searchType=image` | 图片搜索 | 没有，改用 `media` 工具 | 没有 | 没有 | 未测 |
| `filter` | 重复内容过滤 | 没有 | 没有 | 没有 | — |
| `c2coff` | 简繁中文互搜 | 没有 | 没有 | 没有 | — |
| `linkSite`、`lowRange`、`highRange`、`rights` | 链接、数字区间、版权过滤 | 没有 | 没有 | 没有 | — |

这张表有两点要提醒。第一，`cx` 背后是一整套搜索引擎配置：站点列表、排除列表、加权、同义词、精选结果。这些都是在 Google 的控制面板里配的，不在请求里。我们的 `web` 工具没有「搜索引擎」这个概念，站点限定要在每个请求里写 `site`，排除写 `-site:`，加权和精选结果没有对应。如果你的引擎配了几十条站点规则，迁移时要把它们变成一个查询模板。第二，我们的 `web` 工具没有语言参数。Google 的 `hl` 是界面语言、`lr` 是文档语言，在我们这边只有 `web/search` 和 `bing/search` 带 `language`；用 `web` 工具时，查询词本身的语言决定了结果的语言，多数情况够用，但做多语种监控的要改用 `web/search`。

![流程动画，8 秒一圈，青绿色方框依次在六个步骤上移动：01 盘点，列出 cx、参数、日用量；02 映射参数，q、num、start、gl、siteSearch；03 双跑 1 周，同一批查询比 URL 重合；04 切换，保留旧 Key 作回退；05 盯错误，422、空结果、429；06 收尾，12 月 31 日前删旧 Key。](https://everyinfra.com/articles/google-custom-search-api-alternative/fig-02-migration-flow.zh.light.svg)

## 实测一：Google 的参数在 `web` 工具上逐个试

参数对照表是按文档写的，下面是真调。2026 年 11 月 8 日 00:20–00:32（新加坡时间），我们把 Google 最常用的几种写法逐个发给 `web` 工具，再把 Google 的 `start`、`cx` 和 Bing 的 `count` 原样照搬过去，看会发生什么。每一行都对应一次原始返回，耗时是客户端测到的端到端时间。

| 时间（SGT） | 对应 Google 写法 | 我们发的请求 | 结果 | 耗时 | 扣费 |
| --- | --- | --- | --- | --- | --- |
| 00:20:27 | 不带 `key` | 不带 Authorization 头 | 401，「Missing API key」 | 165 ms | $0 |
| 00:20:30 | `start=11` | `"start": 11` | 422，`allowed` 列出 7 个参数 | 211 ms | $0 |
| 00:20:34 | `cx`、`gl` | `"cx": "…"`, `"gl": "us"` | 422，先报 `cx` 不认识 | 111 ms | $0 |
| 00:20:42 | `siteSearch=developers.google.com` | `"site": "developers.google.com"` | 200，0 条，空结果退款 | 1,281 ms | $0 |
| 00:20:51 | `gl=sg` | `"location": "sg"` | 10 条，全部讲新加坡的小贩中心 | 1,591 ms | $0.000694 |
| 00:20:59 | `dateRestrict=m1` | `"after": "2026-10-09"` | 10 条，10 条都带日期，都在 10 月 9 日之后 | 2,437 ms | $0.000694 |
| 00:21:09 | `start=11` | `"page": 2` | 10 条，和第 1 页没有重复 | 1,924 ms | $0.000694 |
| 00:21:18 | `start=101`（Google 会报错） | `"page": 11` | 10 条，只有 2 条还和查询词相关 | 4,285 ms | $0.000694 |
| 00:21:29 | `num=5` | `"num": 5` | 5 条 | 2,376 ms | $0.000694 |
| 00:21:38 | `exactTerms` + `excludeTerms` | `"\"programmable search engine\" -reddit"` | 7 条，7 条都含这个短语，0 条来自 reddit | 2,889 ms | $0.000694 |
| 00:21:48 | `fileType=pdf` | `q` 里写 `filetype:pdf` | 7 条，7 条都是 PDF | 4,533 ms | $0.000694 |
| 00:30:42 | `siteSearch` 写进查询 | `q` 里写 `site:developers.google.com` | 10 条，全部来自该域名 | 1,271 ms | $0.000694 |
| 00:32:05 | `siteSearch=en.wikipedia.org` | `"site": "en.wikipedia.org"` | 9 条，全部来自该域名 | 2,313 ms | $0.000694 |

从这张表能读出四件事。

第一，`site` 参数不稳定，这是本文最需要照实写的发现。同一个域名 developers.google.com，用 `site` 参数发是 0 条，把 `site:developers.google.com` 写进查询词就拿到 10 条，而且 10 条都是 Custom Search 的官方文档页；换成 en.wikipedia.org，两种写法都拿到 9 条。我们还试了 docs.python.org 加「asyncio timeout」，两种写法都是 0 条（00:30:26 和 00:30:34 两次，都按空结果退了款）。同一个查询换到 `bing/search` 上写成 `site:docs.python.org`，17.3 秒后返回 503，所以 Bing 一侧的站点限定本文没有测出结果。所以我们的建议是：迁移时把 Google 的 `siteSearch` 写成查询词里的 `site:`，不要依赖 `site` 参数，并且在双跑阶段专门测你最常限定的那几个域名。好在拿到结果的几次里，没有一条混进别的域名。

第二，翻页没有 100 条的上限，但第 100 条以后的东西基本没用。Google 文档写明「JSON API 永远不会返回超过 100 条结果」，start 加 num 超过 100 会报错。我们的 `page` 翻到第 11 页（相当于第 101–110 条）仍然返回 10 条、照常扣费，但 10 条里只有 2 条还和「custom search json api shutdown」相关，其余是各种技术站点的更新日志。所以如果你的老代码为了绕开 100 条上限做了「拆关键词」的处理，迁移后不必删；但也不要指望靠翻页拿到第 200 条有用的结果。

第三，日期过滤是按日历日写的。Google 的 `dateRestrict=m1` 是「最近一个月」，我们的 `after` 要写具体日期，所以在代码里用今天减 30 天算出来（见下面的代码）。这次 10 条结果里有 6 条是 `google.com/goto` 形式的跳转链接，要再请求一次才能拿到最终网址。实测一里还有一次也是这样：翻到第 11 页那次，10 条里也有 6 条跳转链接；而实测二 `web` 工具的 12 次普通查询一共 114 条结果，一条跳转链接都没有。所以只有带日期过滤和深翻页的调用点，需要在入库前多一步解析跳转。

第四，照搬参数会被拦下，而不是被悄悄忽略。`start`、`cx` 都返回 422，响应里的 `allowed` 写着 `after, before, location, num, page, q, site` 七个参数，`next_steps` 写着「去掉这个参数，没有扣费」。这对迁移是好事：Google 遇到拼错的参数名多数时候直接忽略，老代码里可能藏着从来没生效过的参数，比如把 `dateRestrict` 写成小写的 `daterestrict`。换过来以后它们会第一时间变成 422，看起来像新接口出错，其实是老代码的问题第一次暴露；响应里的 `param` 指出是哪个参数，`allowed` 和 `next_steps` 告诉你怎么改，一次就能改对。

## 实测二：12 个查询、三个入口，结果重合多少

参数能对上，下一个问题是「结果像不像」。我们挑了 12 个查询，覆盖开发者文档、消费品、新加坡本地、墨西哥和西班牙的西语查询、中文查询和英国的站内搜索话题，在 00:22–00:30（新加坡时间）分别发给 `web` 工具、`web/search` 和 `bing/search` 三个入口，一共 36 次，全部 HTTP 200。重合按「去掉协议、www 和末尾斜杠以后的网址」算，跳转链接不计入；表里的条数也是按这个规则去重后的网址数。

| 查询 | 国家 | `web` 去重网址数 | `web/search` 去重网址数 | `bing/search` 去重网址数 | `web` 与 `web/search` 重合 | `web` 与 `bing/search` 重合 | 三家都有 |
| --- | --- | --- | --- | --- | --- | --- | --- |
| google custom search api alternative | us | 10 | 10 | 10 | 10 | 1 | 1 |
| python requests timeout retry | us | 9 | 9 | 10 | 4 | 3 | 1 |
| best running shoes 2026 | us | 9 | 9 | 3 | 7 | 1 | 1 |
| hdb resale flat prices 2026 | sg | 9 | 10 | 7 | 8 | 3 | 3 |
| free weather api | us | 10 | 10 | 9 | 10 | 4 | 4 |
| kubernetes ingress nginx retirement | us | 10 | 10 | 10 | 7 | 5 | 3 |
| receta paella valenciana | es | 8 | 9 | 10 | 7 | 2 | 2 |
| precio del dolar hoy mexico | mx | 10 | 6 | 10 | 6 | 3 | 2 |
| 新加坡 美食 推荐 | sg | 10 | 10 | 8 | 10 | 1 | 1 |
| openai agents sdk mcp tools | us | 9 | 10 | 6 | 6 | 2 | 2 |
| site search for university website | gb | 10 | 10 | 10 | 10 | 3 | 3 |
| bing search api retirement | us | 10 | 10 | 10 | 10 | 1 | 1 |
| 合计 | — | 114 | 113 | 103 | 95 | 29 | 24 |

`web` 工具 12 次共拿回 114 条，其中 95 条在 `web/search` 的结果里也出现了，重合 83%；和 `bing/search` 只重合 29 条，25%。三个入口都出现的网址只有 24 个，三家合起来去重后是 204 个不同的网址。这说明前两个入口给出的结果很接近，`bing/search` 是另一套排序：「bing search api retirement」这个词，`web` 和 `web/search` 的 10 条完全一样，和 `bing/search` 只有 1 条相同。条数也不总是 10：`bing/search` 搜「best running shoes 2026」只回了 3 条，`web/search` 搜墨西哥的「precio del dolar hoy mexico」只回了 6 条，这两次都照常扣了一次的钱（只有 0 条才退款）。所以按「每条结果」算成本时，冷门查询的实际单价会比目录价高，双跑时要把这一点算进去。

![分组条形图：12 个查询各三根条。每个查询里，web 工具与 web/search 的重合条数（青绿色）、web 工具与 bing/search 的重合条数、三家都出现的条数。合计分别是 95、29、24 条，web 工具共 114 条。重合最高的 6 个查询里 web 与 web/search 是 10 条全同，web 与 bing/search 最多 5 条（kubernetes ingress nginx retirement）。](https://everyinfra.com/articles/google-custom-search-api-alternative/fig-05-overlap-bar.zh.light.svg)

对迁移的人，这组数有两个用处。第一，你从 Google 搬过来，结果不会和以前一模一样，任何一家都不会；双跑阶段要看的是「对你的业务够不够用」，不是「重合率多少」。第二，如果你的业务对漏掉某些来源很敏感（比如舆情监控要尽量全），可以同时调 `web` 和 `bing/search`，两边合起来 12 个查询能覆盖 188 个不同网址，比单用一家多出六成以上，而成本是每次 $0.000694 加 $0.000556。

字段方面，三个入口各有长处。下面是 12 个查询里每家返回的字段覆盖率：

| 入口 | 返回条数（未去重） | 带摘要 | 带日期 | 带站内子链接 | 每次价格 |
| --- | --- | --- | --- | --- | --- |
| `web` 工具 | 114 | 110（96.5%） | 46（40.4%） | 0 | $0.000694 |
| `web/search` | 114 | 105（92.1%） | 40（35.1%） | 7（6.1%） | $0.001389 |
| `bing/search` | 103 | 101（98.1%） | 55（53.4%） | 0 | $0.000556 |

![分组条形图：三个入口在 12 个查询里的字段覆盖率。带摘要：web 工具 96.5%（青绿色）、web/search 92.1%、bing/search 98.1%；带日期：40.4%、35.1%、53.4%；带站内子链接：0%、6.1%、0%。](https://everyinfra.com/articles/google-custom-search-api-alternative/fig-06-field-share-bar.zh.light.svg)

日期字段三家都是原样字符串，格式不统一：有「Oct 19, 2026」，也有「5 days ago」，入库前要自己转成日期。Google 的 `items` 里没有统一的日期字段（日期藏在 `pagemap` 的 metatags 里，不是每条都有），所以从这一点看，迁移后能直接拿到的日期反而多了。

## 没有一对一参数时怎么办：hl、safe、searchType、sort

参数对照表里有几行写着「没有」，这几行最容易让迁移卡住，所以单独写清楚各自的替代写法。我们的建议都是在 12 个查询和 13 次参数实测里验证过的思路，不是凭文档推断的等价。

先说 `hl`。Google 的 `hl` 控制的是界面语言，会轻微影响排序，`lr` 才是把结果限定在某种语言。我们的 `web` 工具只有 `location`（国家），没有语言参数；实测二里，西班牙语查询「receta paella valenciana」放在 es，8 条结果里 7 条是西语页面、1 条是英语；墨西哥查询「precio del dolar hoy mexico」放在 mx，10 条全是西语；中文查询「新加坡 美食 推荐」放在 sg，10 条全是中文页面，简体和繁体混在一起（Google 的 `c2coff` 管的就是这件事，我们没有对应开关）。也就是说，在大多数情况下查询词本身的语言加上国家就够了。真要显式指定语言的，用 `web/search`，它有 `language` 参数，每次 $0.001389，比 `web` 工具贵一倍，适合少量必须指定语言的调用点。

再说 `safe`。Google 的 `safe=active` 会过滤成人内容，我们三个入口都没有这个开关。面向儿童、学校或者对品牌安全要求高的产品，迁移时要在自己这一侧加一层过滤：最简单的做法是维护一份域名黑名单，在拿到 `results` 之后按 `url` 的域名剔除；再严格一点，可以把标题和摘要交给你已经在用的内容审核模型。这一层要在双跑阶段就加上，不要等切换以后再补。

然后是 `searchType=image`。Google 用同一个接口加一个参数就能搜图片，我们把图片和视频放在单独的 `media` 工具里，参数是 `q`、`kind` 和 `num`，价格和 `web` 工具一样是每次 $0.000694。返回结构和 `web` 工具不同，所以图片搜索的调用点不能只改参数名，要连解析代码一起改。本文没有对 `media` 工具做真调，这一段只写参数，不写效果。

最后是 `sort=date`。Google 的按日期排序只对配置了结构化数据的引擎有效，很多人用它其实没生效。我们没有排序参数，替代办法是用 `after` 和 `before` 把时间窗收窄，再在自己这一侧按 `date` 字段排。实测一里 `after` 的那次 10 条结果全部带日期，可以直接排序；但日期是原样字符串，有「Oct 19, 2026」和「5 days ago」两种写法，排序前要先统一转换成日期。如果你的需求其实是「最近的新闻」，那更合适的是 `news` 工具或者 `google_news/search`，不过后者在本文的三次尝试里都返回 503，我们没有拿到它的结果数据。

## 返回字段对照：items[] 换成 results[]

参数之外，解析返回的代码也要改。Google 的[返回结构](https://developers.google.com/custom-search/v1/reference/rest/v1/Search)按 OpenSearch 1.1 设计，结果在 `items` 数组里，每条有 `title`、`htmlTitle`、`link`、`displayLink`、`snippet`、`htmlSnippet`、`formattedUrl`、`pagemap` 等字段，外层还有 `searchInformation.totalResults` 和 `queries.nextPage`。我们三个入口的返回字段写在目录的 `response_fields` 里，和本文真调拿到的字段逐个核对过。

| Google 字段 | `web` 工具 | `web/search` | `bing/search` | 说明 |
| --- | --- | --- | --- | --- |
| `items[].title` | `results[].title` | `results[].title` | `results[].title` | 纯文本，没有 `htmlTitle` 的加粗标记 |
| `items[].link` | `url` | `url` | `url` | 少数是跳转链接，见实测一 |
| `items[].displayLink` | 没有，从 `url` 取域名 | 没有 | `displayed_url` | `bing/search` 带面包屑样式 |
| `items[].snippet` | `snippet` | `text` | `text` | 长度约 100–400 个字符 |
| `items[].pagemap` | 没有 | `image_url`（部分） | 没有 | 结构化数据要另取 |
| 无对应 | `published` | `published_at` | `date_text` | 发布日期，原样字符串 |
| 无对应 | 无 | `sub_links`、`rank` | `rank` | 站内子链接、排名 |
| `searchInformation.totalResults` | 没有 | 没有 | 没有 | 不给估算总数 |
| `queries.nextPage` | 自己把 `page` 加 1 | 没有 | 没有 | — |
| 无对应 | `billing.charged_usd` | `billing.charged_usd` | `billing.charged_usd` | 每次实扣多少钱 |

最常踩的坑是 `totalResults`。不少老代码用它判断「有没有结果」或者算总页数；迁移后没有这个字段，要改成看 `results` 是否为空。另一个是 `htmlSnippet`：有些站内搜索页面直接把它塞进 HTML 显示加粗的命中词，迁移后要自己高亮。

## 代码怎么改：一个 Python 函数的前后对照

下面是一段典型的老代码：用 `requests` 调 `customsearch/v1`，拿前 30 条结果。

```text
import requests

def google_cse(q, pages=3):
    out = []
    for i in range(pages):
        r = requests.get("https://www.googleapis.com/customsearch/v1", params={
            "key": GOOGLE_KEY, "cx": CX, "q": q, "num": 10,
            "start": 1 + i * 10, "gl": "sg", "dateRestrict": "m1",
        }, timeout=30)
        items = r.json().get("items", [])
        out += [{"title": x["title"], "url": x["link"], "snippet": x.get("snippet", "")} for x in items]
        if not items:
            break
    return out
```

换成 EveryInfra 的 `web` 工具，改四处：地址和方法（GET 换 POST）、认证（URL 里的 `key` 换成请求头）、参数名（`start` 换 `page`、`gl` 换 `location`、`dateRestrict=m1` 换成具体日期 `after`）、返回字段（`items`/`link` 换成 `results`/`url`）。`cx` 直接删掉。

```text
import os, datetime, requests

def everyinfra_web(q, pages=3):
    after = (datetime.date.today() - datetime.timedelta(days=30)).isoformat()
    out = []
    for page in range(1, pages + 1):
        r = requests.post("https://api.everyinfra.com/api/v1/search",
            headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
            json={"tool": "web", "params": {"q": q, "num": 10, "page": page,
                                            "location": "sg", "after": after}},
            timeout=60)
        r.raise_for_status()
        data = r.json()
        rows = data.get("results", [])
        out += [{"title": x["title"], "url": x["url"], "snippet": x.get("snippet", "")} for x in rows]
        if not rows:   # 空页不扣钱，到这里就停
            break
    return out
```

用 curl 先试一次也行，请求体和上面一样：

```bash
curl -s https://api.everyinfra.com/api/v1/search \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tool":"web","params":{"q":"custom search json api shutdown","num":10,"page":2}}'
```

有两处行为和 Google 不一样，要在代码里处理。第一，不认识的参数返回 422（见实测一第四点），代码里要把 422 当成「改参数」而不是「重试」。第二，429：账户默认每分钟 60 次，超了返回 429 和 `retry_after`，批量任务要按它退避。

## Bing 搜索 API 的替代：从 Bing Web Search v7 迁过来

Bing Web Search API 已经在 2025 年 8 月 11 日下线，还在找 Bing 搜索接口替代品的人，多半是当时临时换了别的方案、现在想再比一次价格。我们的 [`bing/search`](/bing-api/search) 能力按 Bing 的语法搜索，每次返回第一页约 10 条网页结果，目录价每次 $0.000556，也就是每千次 $0.556。下面是 Bing v7 的[查询参数](https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/reference/query-parameters)和我们的对应：

| Bing v7 参数 | 作用 | `bing/search` | 说明 |
| --- | --- | --- | --- |
| `q` | 查询词，支持 `site:` 等高级运算符 | `keyword` | 最多 2,048 字 |
| `count` | 每次条数，默认 10，最多 50 | `limit` | 传 `count` 会返回 422 |
| `offset` | 跳过多少条，用来翻页 | 没有 | 只回第一页 |
| `mkt` | 市场，形如 en-US | `country` + `language` | 拆成两个参数 |
| `setLang` | 界面语言 | `language` | 要和 `country` 一起给才生效 |
| `cc` | 国家代码 | `country` | — |
| `freshness` | Day、Week、Month 或日期区间 | 没有 | 用 `web` 工具的 `after` 代替 |
| `safeSearch` | Off、Moderate、Strict | 没有 | — |
| `responseFilter` | 只要网页、新闻等 | 没有 | 新闻用 `google_news/search` |

从 Bing 搬过来最容易错的是 `count`。00:20:38 那次实测里，我们照 Bing 的习惯传了 `count: 20`，返回 422，`allowed` 列出 `keyword`、`country`、`language`、`limit` 四个参数，管条数的是 `limit`。同一个响应里的 `did_you_mean` 是按拼写相似度给的，写本文时它给的是 `country`，对从 Bing 搬过来的人并不对，所以改参数时以 `allowed` 列表为准。00:31:15 我们改用 `limit: 5` 再发一次，4.46 秒后拿回 5 条，扣 $0.000556。

## 耗时：三个入口端到端多久

Google 的返回里有 `searchInformation.searchTime`，那是服务器内部的搜索耗时；我们测的是客户端从发出请求到收完返回的端到端时间（新加坡发出，经公网），对用户体验更有意义。12 个查询里，`web` 工具中位 1.75 秒，最快 1.27 秒，最慢 2.72 秒；`web/search` 中位 2.16 秒；`bing/search` 中位 4.54 秒，最慢一次 9.25 秒。

![散点图：三个入口各 12 次查询的端到端耗时（秒）。web 工具 12 个点集中在 1.27 到 2.72 秒，中位 1.75 秒，青绿色；web/search 在 1.48 到 2.80 秒，中位 2.16 秒；bing/search 在 2.74 到 9.25 秒，中位 4.54 秒。](https://everyinfra.com/articles/google-custom-search-api-alternative/fig-07-latency-scatter.zh.light.svg)

如果你的老代码是网页上的站内搜索，用户在等结果，`web` 工具的 1–3 秒和 Google 的体验接近；`bing/search` 的 4–9 秒不适合放在用户等待的路径上，更适合后台批量任务。另外，本文的 4 次「服务暂时不可用」里有 1 次是 `bing/search` 在 17.3 秒后返回 503，所以后台任务要设 60 秒以上的超时和重试。

## 失败、空结果和报错：哪些情况扣钱

Google 的文档没有写失败请求扣不扣钱，只写了按查询次数计费；SerpAPI 的定价页写明「只有成功的搜索计数，缓存、出错和失败的不算」，同时写「返回 100 条和返回空结果都算 1 次」。我们的规则是失败和空结果都不扣钱。本文一共真调 59 次，扣费 48 次，合计 $0.039858；下面是其余 11 次没扣钱的真调，每一条都有原始返回：

| 时间（SGT） | 入口 | 情况 | HTTP | 扣费 | 返回里怎么说 |
| --- | --- | --- | --- | --- | --- |
| 00:20:27 | `web` | 没带 Key | 401 | $0 | 「Nothing was charged」 |
| 00:20:30 | `web` | 照搬 Google 的 `start` | 422 | $0 | 列出 7 个可用参数 |
| 00:20:34 | `web` | 照搬 Google 的 `cx` | 422 | $0 | 同上 |
| 00:20:38 | `bing/search` | 照搬 Bing 的 `count` | 422 | $0 | `did_you_mean` 给了 `country`（应为 `limit`） |
| 00:20:42 | `web` | `site` 参数，0 条 | 200 | $0 | `empty_result_refunded` |
| 00:22:00 | `google_news/search` | 服务暂时不可用，第 1 次尝试 | 503 | $0 | `retry_after: 60`，3 次里第 1 次失败 |
| 00:30:26 | `web` | `site` 参数，0 条 | 200 | $0 | `empty_result_refunded` |
| 00:30:34 | `web` | 查询里写 `site:`，0 条 | 200 | $0 | `empty_result_refunded` |
| 00:30:51 | `bing/search` | 服务暂时不可用，17.3 秒 | 503 | $0 | `request_failed_refunded` |
| 00:31:26 | `google_news/search` | 服务暂时不可用，第 2 次尝试（隔 9 分 26 秒） | 503 | $0 | 3 次里第 2 次失败 |
| 00:32:24 | `google_news/search` | 服务暂时不可用，第 3 次尝试（隔 58 秒，去掉 `time_window`） | 503 | $0 | 仍写 3 次里第 2 次失败 |

`google_news/search` 的 503 返回里写着 `retryable: true`、`retry_after: 60` 和 `max_retries: 2`，`next_steps` 写明「没有扣费」，并说这是 3 次里的第几次失败，第 3 次会告诉你该查什么。我们实际的三次尝试间隔是 9 分 26 秒和 58 秒，第三次还去掉了 `time_window` 参数，三次都返回 503，说明这段时间里它是持续不可用，不是偶发的一次失败。批量任务照着 `retry_after` 退避、重试不超过 `max_retries` 就够了，不必自己猜等多久。所以本文没有它的结果数据，新闻类迁移我们只写参数，不写效果；如果你的老代码里有新闻搜索，双跑阶段要单独测它。

空结果退款这一条对迁移特别有用。双跑阶段你会把一批老查询原样发过来，其中一些在新接口上可能没有结果（比如上面那次 `site` 参数的请求），这些请求不会产生费用；你只为拿到结果的请求付钱。

![接口返回截图：一张深色代码卡片，上面是请求，tool 为 web，查询词是带引号的 programmable search engine，后面加减号排除 reddit，num 为 10；下面是返回，截取两条结果，分别是 developers.google.com/custom-search 和 support.google.com/programmable-search，published 为空；最后一行 billing 里的 charged_usd 0.000694 用青绿色框标出。卡片顶部写着 2026-11-08 00:21:38 SGT，HTTP 200，2889 ms。](https://everyinfra.com/articles/google-custom-search-api-alternative/img-shot-response.webp)

一次真实返回：引号短语加排除词，7 条结果，扣 $0.000694。 [EveryInfra 接口真实返回截图](https://api.everyinfra.com/api/v1/search/tools)

## 接进 AI agent：MCP 配置和一次往返

很多人用 Custom Search JSON API 不是为了做网页，而是给 agent 当搜索工具。我们的远程 MCP 地址是 `https://api.everyinfra.com/mcp`，在 2026 年 11 月 8 日 00:2x（新加坡时间）不带 Key 调 `tools/list` 返回 12 个工具，搜索用的是 `everyinfra_search`，参数是 `tool` 和 `params`，和 REST 接口的请求体一样。Claude Code、Cursor 这类支持远程 MCP 的客户端，配置写成这样：

```text
{
  "mcpServers": {
    "everyinfra": {
      "type": "http",
      "url": "https://api.everyinfra.com/mcp",
      "headers": { "Authorization": "Bearer ${EVERYINFRA_API_KEY}" }
    }
  }
}
```

00:31:56（新加坡时间），我们通过 MCP 调了一次 `everyinfra_search`，参数是 `{"tool": "web", "params": {"q": "custom search json api discontinued january 1 2027", "num": 5}}`。2.35 秒后返回 5 条结果，第一条就是 Google 的 Custom Search JSON API 概览页，摘要里写着「Existing Custom Search JSON API customers have until January 1, 2027」，日期是 Feb 18, 2026，和我们直接读那一页看到的「最后更新 2026-02-18」一致；这次扣费 $0.000694，和 REST 接口同价。模型拿到的是和 REST 一样的 JSON，包括 `billing.charged_usd`，所以 agent 自己就能记账。

如果你原来是在 LangChain 之类的框架里用 Google 搜索的包装类，迁移时最省事的做法是自己写一个十来行的工具函数（就是上一节的 `everyinfra_web`），把它注册成框架的工具；这样搜索供应商再换一次，只改这个函数。MCP 协议本身在 [2026-07-28 版规范](https://modelcontextprotocol.io/specification/2026-07-28/changelog)里去掉了初始化握手、改成无状态，远程服务器的接入比一年前简单，[我们的 MCP 页面](/mcp-server)列了各客户端的配置写法。

## 什么时候别家更合适

迁移不一定要搬到我们这里。下面几种情况，别的选择更合适，我们照实写：

| 你的情况 | 更合适的选择 | 理由 |
| --- | --- | --- |
| 只搜自己公司的 50 个以内域名，要嵌在网页上 | Programmable Search Element | 免费，Google 继续提供；我们没有嵌入式搜索框 |
| 站内搜索要按自己的规则排序、要生成式回答 | Google Agent Search 企业版 | 能建索引、加权、控制排序；我们只给开放网页结果 |
| 每月几百万次以上，只要标题链接摘要 | Serper Ultimate 档 | 公开价每千次 $0.30，比我们的 $0.694 低；注意 credits 6 个月过期 |
| 要完整结果页：广告、知识面板、地图包、购物 | SerpAPI、Bright Data SERP API | 返回整页结构化 JSON；SerpAPI 页面列出几十种引擎 |
| agent 要搜索结果附带正文片段，一次调用就够 | Tavily | 每条结果带相关片段；我们要 `web` 加 `read` 两步 |
| 要把整站爬下来转成 Markdown | Firecrawl | crawl 是它的主业；我们的 `crawl` 工具一次最多 20 页 |
| 必须是 Google 自己出具的结果和合同 | 申请 Google 全网搜索方案 | 只有 Google 能给；价格未公开 |

SerpAPI 有一点值得单独提：它的定价页写着「U.S. Legal Shield」，在高档套餐里为抓取和解析搜索结果提供最高 $2 百万的法律保障。如果你的法务部门把这一项列为必要条件，这是我们没有的东西。Serper 的 credits 6 个月过期这一点，我们在 [Serper 替代那篇](/blog/serper-api-alternative)里按月用量算过：每月 1,000 次的人折算下来每千次实付 $8.33。

## 我们做不到的

这一节写边界，写给要做决定的人。我们的 `web` 工具不是 Google 的官方接口，返回的排序和 google.com 上看到的不保证一致，也不提供「这就是 Google 排名」的保证；做排名追踪、SEO 报表的，要的是逐位排名和完整结果页，应该选 SerpAPI 这类专做结果页的服务，或者用我们的 [`web/search`](/web-api/search)（带 `rank` 字段）先测一批词再决定。我们没有图片搜索的 `searchType=image` 对应参数，图片和视频要用 `media` 工具，参数完全不同。我们没有 SafeSearch 开关，面向儿童或学校的产品要自己做过滤。我们的 `web` 工具没有语言参数。我们没有每日 1 万次这种硬上限，但每分钟默认 60 次，突发流量要排队。最后，我们不提供 Google 那种带广告的免费嵌入式搜索框，站内搜索的界面要你自己做。

还有两点和迁移直接相关。第一，我们的价格是按次扣的预付余额，没有 Google Cloud 那种月底出账单的方式，也没有承诺用量的折扣合同；需要发票和对公付款的团队，要先确认财务流程能接受预付。第二，我们没有 Google 那样的服务等级协议文本可以直接放进你的采购合同里，本文实测中 `google_news/search` 三次 503、`bing/search` 一次 503，这些都如实写在上面的表里。对可用性要求很高的调用点，建议同时接两个入口，一个失败就换另一个，两边都失败不扣钱。

## 切换以后看哪三个数

切换不是终点。新接口上线后的头两周，建议每天看三个数，它们都能直接从返回里算出来，不需要额外的监控系统。

第一个数是空结果比例，即 `results` 为空的返回占多少。它升高时先查是不是有调用点在用 `site` 参数（见实测一第一点）。空结果不扣钱，所以这个数升高不会让账单变大，但会让你的产品看起来「搜不到东西」，用户比账单先感觉到。

第二个数是 422 的次数。把每次 422 返回里的 `param` 字段记下来，按出现次数排序；切换后的头一两天它们往往集中在很少被调用的老功能上，比如只在月底跑的报表脚本，清干净以后应该接近 0。

第三个数是每天的扣费合计。把每次返回里的 `billing.charged_usd` 加起来，和你按调用次数估算的数对一下：`web` 工具每次 $0.000694，`bing/search` 每次 $0.000556，`web/search` 每次 $0.001389。如果实际扣费明显高于估算，多半是有循环在重复调用同一个查询，或者翻页逻辑没有停止条件；Google 那边有每天 1 万次的硬上限挡着，我们这边没有，所以翻页一定要写明最多翻几页。

## 迁移检查单：六步做完

把上面的内容收成一张检查单。每一步写一个动作和它为什么重要；按这个顺序做，12 月中旬就能切换完，留出两周缓冲。

1. 盘点：在代码里搜 `customsearch/v1` 和 `cx=`，列出每个调用点用了哪些参数、每天大概多少次。
1. 映射参数：按上面的参数对照表改名；用到 `safe`、`searchType=image`、`sort` 的调用点单独标出来，它们没有一对一的替代。
1. 双跑一周：同一批真实查询同时发给老接口和新接口，比 URL 重合、空结果比例和耗时。
1. 切换：新接口作为主路径，老 Key 留着作回退，直到 12 月下旬。
1. 盯错误：重点看 422（漏改的参数）、空结果（`site` 写法）和 429（并发超了每分钟上限）。
1. 收尾：在 2026 年 12 月 31 日前删掉老的 `cx` 和 Google Key，免得 1 月 1 日之后的报错被当成新问题排查。

第 3 步最容易被跳过，也最重要。我们自己的实测显示，同一个查询在不同入口上的结果重合度并不高（见实测二），这不是哪一边错了，而是不同搜索服务本来就各有排序。双跑的目的不是追求「和 Google 一模一样」，而是确认新结果对你的业务够用：如果你的产品是「搜一个品牌名，看前 10 条有没有负面新闻」，那就拿 50 个真实品牌名各搜一次，人工看一遍；如果是「搜官网地址」，就看第一条是不是官网。判据要在双跑之前写好，不要看了结果再定。

双跑本身也要花钱，但不多。按每天 500 个真实查询、双跑 7 天算，一共 3,500 次：只跑 `web` 工具是 3,500 × $0.000694 = $2.43；如果同时比 `web` 和 `bing/search`，再加 3,500 × $0.000556 = $1.95，合计 $4.38。Google 那一侧每天前 100 次免费，其余 400 次按 $5/千次是每天 $2.00，7 天 $14.00。也就是说，一周双跑的全部费用不到 $20，比一次线上事故便宜得多。空结果和失败不扣钱，所以双跑时故意多放一些冷门查询和限定域名的查询也不会多花钱。

## 最近的变化（2026 年 10 月到 11 月）

搜索 API 这一块在最近一个月里变化很快，下面几条和迁移直接相关，每条都写了对读者意味着什么：

| 日期 | 变化 | 对你意味着什么 |
| --- | --- | --- |
| 2026-10-16 | Google 社区经理在 Programmable Search 帮助论坛重贴 1 月的停服说明 | 截止日没有延后的迹象，按 1 月 1 日计划 |
| 2026-10-23 | Firecrawl 发布 Google Search JSON API 迁移文章，列出 10 月 23 日读到的各家价格 | 第三方都在争这批迁移用户，比价时以各家定价页原文为准 |
| 2026-10-27 | 帮助论坛又有老项目报告 403「project has no access」 | 老客户也可能提前失去访问，别等到 12 月最后一周 |
| 2026-11-03 | SerpAPI 的 MCP 服务器发布 [v2.1.0](https://github.com/serpapi/serpapi-mcp/releases)，刷新各引擎参数；11 月 4 日 v2.2.0 加了 extract 工具 | 结果页类服务开始补「读正文」，和搜索类服务的边界在变 |
| 2026-11-06 | AddSearch 发布站内搜索迁移指南，按「50 个域名以内 / 以上 / JSON API」分三类 | 站内搜索用户的选择和全网搜索用户不同，先分清自己是哪类 |

其中 10 月 27 日那条要特别注意。帖子标题是「[Custom Search JSON API 403: project has no access despite enabled API and configured engine](https://support.google.com/programmable-search/thread/474893537/custom-search-json-api-403-project-has-no-access-despite-enabled-api-and-configured-engine?hl=en)」，发帖人说 API 在控制台显示已启用、引擎也配好了，但请求返回 403。类似的帖子从 2 月开始就有（[2 月 21 日那篇](https://support.google.com/programmable-search/thread/411852630/requests-to-google-custom-search-api-fail-with-403-this-project-does-not-have-the-access-to-custom?hl=en)），说明「老客户能用到 1 月 1 日」在个别项目上不一定成立。如果你的业务离不开搜索，现在就该开始双跑。

## 上手：三步把搜索换过来

第一步，在[快速上手](/docs#quickstart)里注册并拿到 API Key；新账户在 GitHub 给 everyinfra/everyinfra-agent-plugins 和 everyinfra/seo-skills 两个仓库都点星后，可以在控制台领 $1 试用额度，约 1,440 次 `web` 搜索，领取后 24 小时内有效。第二步，用上面的 curl 先搜一次你最常用的查询，看返回的 `results` 和 `billing.charged_usd`。第三步，把代码里的调用换成上面的 Python 函数，或者在 agent 里加上 MCP 配置。搜索工具的完整说明在[网页搜索产品页](/products/search/web)，各平台的数据接口在[基础设施市场](/market)可以直接在线试，价格在[价格页](/pricing)。要按国家、语言搜的，看 [`web/search` 能力页](/web-api/search)；要 Bing 的，看 [`bing/search`](/bing-api/search)；要新闻的，看 [`google_news/search`](/google-news-api/search)。平台总览分别在 [Web 搜索](/web-api)、[Bing](/bing-api) 和 [Google News](/google-news-api) 页面。

## 常见问题

**Google 还有搜索 API 吗？**

有，但对新开发者来说已经没有能自助开通的全网搜索 API。Custom Search JSON API 不收新客户，2027 年 1 月 1 日停服；Agent Search 只覆盖 50 个以内的域名；全网搜索方案要填表申请，价格没公开。这个问题来自 Google 搜索联想词「is there a google search api」「does google have a search api」。

**Google 搜索 API 怎么收费，有免费的吗？**

按 Google 原文：老客户每天前 100 次免费，之后每 1,000 次 $5，每天最多 1 万次，到 2027 年 1 月 1 日为止，所以每天用满 1 万次时一个月是 $1,485。Agent Search 企业版是每 1,000 次 $4.00，每月前 1 万次试用免费；Programmable Search Element 的嵌入式搜索框免费但带广告。没有永久免费的全网 JSON 搜索接口。问题来自联想词「google search api pricing」「google custom search api pricing」「is google search api free」。

**Google Custom Search API 停了以后，60k 次/月的全网搜索用什么最便宜？**

Reddit 的 r/googlecloud 有一篇[原帖](https://www.reddit.com/r/googlecloud/comments/1qp4mlz/google_custom_search_api_is_closing_need/)问的就是这个：每月 4 万次、很快 6 万次，要全网，不要限定域名，希望接近 $5/千次。按本文的价格表，每月 6 万次在我们的 `web` 工具上是 $41.64，`bing/search` 是 $33.36，Serper Starter 包 $50 买 5 万次、半年内用完；SerpAPI 的 Searcher 档每月 $725 买 10 万次。要不要换，取决于你要不要完整结果页。

**Bing 搜索 API 下线了，有哪些替代？**

微软官方推荐的是 Grounding with Bing Search，每 1,000 次 $14，只能在 Azure AI Foundry 里用，拿不到原始结果。要原始结果的，可以用结果页类服务（SerpAPI、Bright Data 都支持 Bing），或者我们的 `bing/search`，每 1,000 次 $0.556。问题来自联想词「bing search api alternative」「bing search api replacement」。

**Custom Search API 返回 403「This project does not have the access」是怎么回事？**

这是 2026 年 1 月 20 日之后新建项目调用时的标准报错，Google 社区经理在帮助论坛的[这篇帖子](https://support.google.com/programmable-search/thread/411852630/requests-to-google-custom-search-api-fail-with-403-this-project-does-not-have-the-access-to-custom?hl=en)里确认过；10 月 27 日也有老项目报告同样的错误。新项目没有办法再开通，只能换接口。问题来自 Google 搜索相关词「This project does not have the access to Custom Search JSON API」。

## 参考资料

1. [Custom Search JSON API Overview（不收新客户、2027-01-01 截止、$5/千次、每天 100 次免费、每天上限 1 万次）](https://developers.google.com/custom-search/v1/overview)，Google for Developers，2026-02-18 更新，2026-11-08 读取。
1. [Method: cse.list（q、num、start、gl、hl、cr、lr、siteSearch、dateRestrict、safe、searchType 等参数）](https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list)，Google for Developers，2026-11-08 读取。
1. [Search 返回结构（items、searchInformation、queries.nextPage）](https://developers.google.com/custom-search/v1/reference/rest/v1/Search)，Google for Developers，2026-11-08 读取。
1. [Custom Search JSON API: Introduction（Key、cx、OpenSearch 1.1）](https://developers.google.com/custom-search/v1/introduction)，Google for Developers，2026-11-08 读取。
1. [Using REST to Invoke the API（请求 URL、单查询最多 100 条）](https://developers.google.com/custom-search/v1/using_rest)，Google for Developers，2026-11-08 读取。
1. [Custom Search Site Restricted JSON API（2025-01-08 已停止）](https://developers.google.com/custom-search/v1/site_restricted_api)，Google for Developers，2026-11-08 读取。
1. [site: search operator](https://developers.google.com/search/docs/monitor-debug/search-operators/all-search-site)，Google Search Central，2026-11-08 读取。
1. [Custom Search JSON API 请求地址](https://www.googleapis.com/customsearch/v1)，Google，2026-11-08 读取。
1. [Updates to our Web Search Products（新引擎只能限定站点、最多 50 个域名）](https://programmablesearchengine.googleblog.com/2026/01/updates-to-our-web-search-products.html)，Programmable Search Engine Blog，2026-01-20，2026-11-08 读取。
1. [Update sites in your search engine（2026-01-20 起的变化）](https://support.google.com/programmable-search/answer/12397162?hl=en)，Programmable Search Engine Help，2026-11-08 读取。
1. [社区帖：Updates to our web search products](https://support.google.com/programmable-search/thread/473199482/updates-to-our-web-search-products-programmable-search-engine-capabilities?hl=en)，Programmable Search Engine Community，2026-10-16 有新回复，2026-11-08 读取。
1. [社区帖：Custom Search JSON API 403, project has no access](https://support.google.com/programmable-search/thread/474893537/custom-search-json-api-403-project-has-no-access-despite-enabled-api-and-configured-engine?hl=en)，Programmable Search Engine Community，2026-10-27，2026-11-08 读取。
1. [社区帖：403「This project does not have the access to Custom Search JSON API」](https://support.google.com/programmable-search/thread/411852630/requests-to-google-custom-search-api-fail-with-403-this-project-does-not-have-the-access-to-custom?hl=en)，Programmable Search Engine Community，2026-11-08 读取。
1. [社区帖：Custom Search API Full web search solution（社区经理回复：已不收新客户）](https://support.google.com/programmable-search/thread/414354926/custom-search-api-full-web-search-solution?hl=en)，Programmable Search Engine Community，2026-03-03 回复，2026-11-08 读取。
1. [Migrate from Custom Search JSON API](https://docs.cloud.google.com/generative-ai-app-builder/docs/migrate-from-cse)，Google Cloud，2026-11-08 读取。
1. [Vertex AI 产品改名对照（Vertex AI Search 改为 Agent Search）](https://docs.cloud.google.com/gemini-enterprise-agent-platform/vertex-ai-name-changes)，Google Cloud，2026-11-08 读取。
1. [Agent Search pricing（Standard $1.50、Enterprise $4.00 每千次，每月 1 万次试用）](https://cloud.google.com/generative-ai-app-builder/pricing)，Google Cloud，2026-11-08 读取。
1. [Google Documents Partner-Only API For Full Web Search Results](https://www.searchenginejournal.com/google-documents-partner-only-api-for-full-web-search-results/589194/)，Search Engine Journal，2026-09-11，2026-11-08 读取。
1. [Google Web Search Service API Documentation Removed](https://www.seroundtable.com/google-web-search-service-api-documentation-removed-42168.html)，Search Engine Roundtable，2026-09-28，2026-11-08 读取。
1. [Google documents a partner-only Web Search Service API as Custom Search shutdown nears](https://seoforum.com/news/google-documents-a-partner-only-web-search-service-api-as-custom-search-shutdown-nears)，SEO Forum，2026-11-08 读取。
1. [Bing Search API retirement（2025-08-11 退役）](https://learn.microsoft.com/en-us/lifecycle/announcements/bing-search-api-retirement)，Microsoft Learn，2026-11-08 读取。
1. [Bing Web Search API v7 query parameters（q、count、offset、mkt、setLang、freshness）](https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/reference/query-parameters)，Microsoft Learn，2026-11-08 读取。
1. [Grounding with Bing Search（结果只能给 agent 用，不能拿原始结果）](https://learn.microsoft.com/en-us/azure/ai-services/agents/how-to/tools/bing-grounding?view=azure-python-preview&tabs=python&pivots=overview)，Microsoft Learn，2026-11-08 读取。
1. [Grounding with Bing Search pricing（$14/千次）](https://www.microsoft.com/en-us/bing/apis/grounding-pricing)，Microsoft，2026-11-08 读取。
1. [SerpApi Pricing](https://serpapi.com/pricing)，SerpApi，2026-11-08 读取。
1. [SerpApi Google Search API 文档](https://serpapi.com/search-api)，SerpApi，2026-11-08 读取。
1. [serpapi-mcp releases（v2.1.0、v2.2.0）](https://github.com/serpapi/serpapi-mcp/releases)，GitHub，2026-11-03 / 2026-11-04，2026-11-08 读取。
1. [Serper 首页（定价、2,500 次免费、6 个月有效）](https://serper.dev/)，Serper，2026-11-08 读取。
1. [Tavily Pricing](https://www.tavily.com/pricing)，Tavily，2026-11-08 读取。
1. [Tavily API Credits（basic search 1 credit）](https://docs.tavily.com/documentation/api-credits)，Tavily Docs，2026-11-08 读取。
1. [tavily-mcp releases](https://github.com/tavily-ai/tavily-mcp/releases)，GitHub，2026-11-08 读取。
1. [Firecrawl Pricing](https://www.firecrawl.dev/pricing)，Firecrawl，2026-11-08 读取。
1. [Firecrawl Billing（search 每 10 条 2 credits）](https://docs.firecrawl.dev/billing)，Firecrawl Docs，2026-11-08 读取。
1. [firecrawl-mcp-server releases（v3.36.1）](https://github.com/firecrawl/firecrawl-mcp-server/releases)，GitHub，2026-11-03，2026-11-08 读取。
1. [Google Search JSON API alternative](https://www.firecrawl.dev/blog/google-search-json-api-alternative)，Firecrawl Blog，2026-10-23，2026-11-08 读取。
1. [Bright Data SERP API pricing](https://brightdata.com/pricing/serp)，Bright Data，2026-11-08 读取。
1. [Bright Data SERP API introduction](https://docs.brightdata.com/scraping-automation/serp-api/introduction)，Bright Data Docs，2026-11-08 读取。
1. [google-api-python-client releases（v2.201.0）](https://github.com/googleapis/google-api-python-client/releases)，GitHub，2026-09-30，2026-11-08 读取。
1. [OpenSearch 1.1 draft 6（Custom Search 返回结构的来源规范）](https://github.com/dewitt/opensearch/blob/master/opensearch-1-1-draft-6.md)，GitHub，2026-11-08 读取。
1. [MCP specification 2026-07-28 changelog](https://modelcontextprotocol.io/specification/2026-07-28/changelog)，Model Context Protocol，2026-07-28，2026-11-08 读取。
1. [Migrating Off Google Programmable Search Before the 2027 Deadline](https://www.addsearch.com/blog/migrating-off-google-programmable-search-before-2027-deadline/)，AddSearch，2026-11-06，2026-11-08 读取。
1. [Google Custom Search API is closing. Need affordable Open Web Search alternative for 60k req/month](https://www.reddit.com/r/googlecloud/comments/1qp4mlz/google_custom_search_api_is_closing_need/)，Reddit r/googlecloud，2026-11-08 读取。
1. [Is Google's Custom Search API being discontinued?（2026-01-20 当天新 Key 403）](https://www.reddit.com/r/googlecloud/comments/1qilhrg/is_googles_custom_search_api_being_discontinued/)，Reddit r/googlecloud，2026-11-08 读取。
1. [Google quietly announced that Programmable Search won't allow new engines to search the entire web](https://news.ycombinator.com/item?id=46730437)，Hacker News，2026-11-08 读取。
1. [Google Search for Discourse AI（2026 年 3 月的停用说明）](https://meta.discourse.org/t/google-search-for-discourse-ai-programmable-search-engine-and-custom-search-api/307107?tl=en)，Discourse Meta，2026-11-08 读取。
1. [EveryInfra 搜索工具目录（web 工具参数与价格）](https://api.everyinfra.com/api/v1/search/tools)，EveryInfra，2026-11-08 00:14:49 SGT 读取，2026-11-08 读取。
1. [EveryInfra 数据接口目录（web/search、bing/search、google_news/search）](https://api.everyinfra.com/api/v1/social/catalog)，EveryInfra，2026-11-08 00:14:49 SGT 读取，2026-11-08 读取。
1. [EveryInfra 远程 MCP 端点（everyinfra_search）](https://api.everyinfra.com/mcp)，EveryInfra，2026-11-08 读取。
