Catalog / Cloudflare Developer Platform
Agents - New web_search tool in the Agents SDK, powered by the Cloudflare Web Search API
The Cloudflare Agents SDK now provides a web_search tool that searches the public web through the Cloudflare Web Search API, powered by ceramic.ai, Exa, and Linkup.
When you give the web_search tool to your agent, the model provides a query and max results, and receives back a short numbered list of titles, URLs, and trimmed descriptions. When you also provide the web_fetch tool to your agent, the model is told to use it to read the pages that the web_search tool returns.
To use the web_search tool, make sure you have Agents SDK v0.27.0 ↗︎ or greater installed, and add it to a Pi Durable extension registry before opening the harness:
import { webSearchTool } from "agents/websearch/pi";
export class MyAgent extends DurableObject {
// ...
harness = new PiHarness({
harness: async ({ storage, context }) => {
this.registry.install({
name: "web-tools",
tools: [webSearchTool({ binding: this.env.AI, provider: "exa" })],
});
// ...
return Harness.open(
storage,
{ models, registry: this.registry },
context,
);
},
});
}import { webSearchTool } from "agents/websearch/pi";
export class MyAgent extends DurableObject<Env> {
// ...
readonly harness = new PiHarness({
harness: async ({ storage, context }) => {
this.registry.install({
name: "web-tools",
tools: [webSearchTool({ binding: this.env.AI, provider: "exa" })],
});
// ...
return Harness.open(
storage,
{ models, registry: this.registry },
context,
);
},
});
}
The SDK also includes AI SDK and TanStack AI adapters. To search without a model, such as from a scheduled job, use createAIWebSearch() or createHTTPWebSearch() from agents/websearch.
For setup, options, and error handling, refer to Web search.