Give Your AI Agents Web Search: Web Search API Arrives in Beta
Hi everyone, it's Shii-chan! Today is a new API that lets your agents work with fresh information.
Cloudflare ChangelogWhat was announced?
The Cloudflare Changelog announced Web Search API in beta. It 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.
What changes
At launch you can choose between three search providers:
- Ceramic.ai
- Exa
- Linkup
All three support Zero Data Retention for requests made through Cloudflare, and all have committed to Cloudflare's verified bot crawling standards.
Dive Deep
Web Search API runs through AI Gateway:
- Search requests appear in your gateway logs
- They 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
A REST API call:
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" } }
}'
From a Worker with the AI binding:
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();
For the full steps, see the "How to use Web Search API" guide.
Wrap-up
- Web Search API is in beta and runs through AI Gateway
- Pick Ceramic.ai, Exa, or Linkup, or bring your own key
- Billed at provider list prices with no Cloudflare markup
- Callable via REST or the Workers AI binding
A great fit if you want your agents to know what's happening right now!