Web Search API

Web Search API

October 2, 2026 2026年10月2日

Web Search API is now available in beta. Web Search API lets your AI agents and applications search the Internet and ground their responses in live information, instead of guessing URLs or relying on a model’s training cutoff. Web Search API 现已推出测试版。Web Search API 让您的 AI 智能体和应用程序能够搜索互联网,并基于实时信息生成回复,而无需猜测 URL 或依赖模型的训练截止日期。

At launch, you can choose between three search providers: Ceramic.ai, Exa, and Linkup. All three support Zero Data Retention for requests made through Cloudflare, and all have committed to Cloudflare’s verified bot crawling standards. 在发布初期,您可以选择三家搜索服务提供商:Ceramic.ai、Exa 和 Linkup。这三家服务商均支持通过 Cloudflare 发出的请求实现“零数据保留”(Zero Data Retention),并且都承诺遵守 Cloudflare 的已验证机器人爬取标准。

Web Search API runs through AI Gateway, so search requests appear in your gateway logs and are billed to your AI Gateway credits at each provider’s list API price, with no additional markup. You can also bring your own provider API key. Web Search API 通过 AI Gateway 运行,因此搜索请求会显示在您的网关日志中,并按各提供商的公开 API 价格从您的 AI Gateway 额度中扣除,不会有任何额外加价。您也可以使用自己提供的 API 密钥。

Call Web Search API with the REST API: 通过 REST API 调用 Web Search API:

curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/websearch/ \
  --request POST \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "query": "What are some fun things to do in Salt Lake City as fall approaches?",
    "provider": "ceramic",
    "limit": 5,
    "options": {
      "gateway": {
        "id": "default"
      }
    }
  }'

Or from a Worker with the AI binding: 或者通过带有 AI 绑定的 Worker 进行调用:

const response = await env.AI.websearch({
  gatewayId: "default",
  query: "What are some fun things to do in Salt Lake City as fall approaches?",
  provider: "exa",
  limit: 5,
});

const results = await response.json();

To get started, refer to How to use Web Search API. 如需开始使用,请参考“如何使用 Web Search API”。