Guides and reference for the Cloudflare AI packages: providers and adapters for the Vercel AI SDK and TanStack AI, backed by Workers AI, AI Gateway, and AI Search.
flowchart TD
app["Your Worker / app"]
wai["workers-ai-provider<br/>(Vercel AI SDK)"]
ais["ai-search-provider<br/>(Vercel AI SDK)"]
tan["@cloudflare/tanstack-ai<br/>(TanStack AI)"]
agp["ai-gateway-provider<br/>(Vercel AI SDK)"]
gw["AI Gateway / Workers AI<br/>(env.AI binding · REST)"]
search["AI Search<br/>(env.AI_SEARCH binding)"]
app --> wai
app --> ais
app --> tan
app --> agp
wai --> gw
ais --> search
tan --> gw
agp --> gw
These packages split by backend. workers-ai-provider, @cloudflare/tanstack-ai, and ai-gateway-provider all reach Workers AI / AI Gateway through the env.AI binding (or its REST API), so they share the same gateway routing, cf-aig-* header building, resumable-stream engine, and SSE handling. ai-search-provider targets the env.AI_SEARCH binding instead, so it's a standalone provider with its own request/response mapping.
| You are using… | Use | Docs |
|---|---|---|
Vercel AI SDK (ai) |
workers-ai-provider |
Workers AI models + the AI Gateway delegate (unified catalog, resume (coming soon), server-side fallback) |
Vercel AI SDK (ai) + AI Search |
ai-search-provider |
Upload files to AI Search for indexing, then search with natural language or generate grounded chat responses |
TanStack AI (@tanstack/ai) |
@cloudflare/tanstack-ai |
Workers AI + gateway adapters, with resumable streaming (coming soon) |
Gateway routing for pre-built @ai-sdk/* models |
ai-gateway-provider |
Wrap Vercel AI SDK model instances and route them through AI Gateway (caching, retries, cross-vendor fallback) |
- Gateway routing — how a
vendor/modelslug is routed to the run path or the gateway path, unified vs BYOK billing, and server-side fallback. - Resumable streaming (coming soon) — how transient
mid-stream drops reconnect transparently via
cf-aig-run-id, and where resume is (and isn't) available. - Binding vs REST — the
env.AIbinding versus the REST API, and what each transport supports.