Feature
Use AI Search with the Agents SDK, AI SDK, and LangChain
You can now use AI Search directly from popular agent frameworks, adding grounded retrieval to an existing app instead of calling the REST API by hand. The new Agents section has guides for the Vercel AI SDK, LangChain, and the Cloudflare Agents SDK. The AI SDK integration is a new package, and the LangChain integration is a new retriever in the existing langchain-cloudflare package.
Vercel AI SDK
The ai-search-provider package connects AI Search to the AI SDK, and targets AI SDK v6 (ai@^6). Pass instance.chat() to generateText or streamText to generate a response grounded in your indexed content, with the retrieved chunks returned as sources. You can also expose instance.search() as a tool for agent loops.
import { createAISearchNamespace } from "ai-search-provider"; import { generateText } from "ai"; const aiSearch = createAISearchNamespace({ binding: env.AI_SEARCH }); const { text, sources } = await generateText({ model: aiSearch.get("knowledge-base").chat(), messages: [{ role: "user", content: "How does caching work?" }], });
import { createAISearchNamespace } from "ai-search-provider"; import { generateText } from "ai"; const aiSearch = createAISearchNamespace({ binding: env.AI_SEARCH }); const { text, sources } = await generateText({ model: aiSearch.get("knowledge-base").chat(), messages: [{ role: "user", content: "How does caching work?" }], });
LangChain
The langchain-cloudflare package (PyPI,
Read the original announcement