AI
Product map for Cloudflare AI, retrieval, and supporting storage
Product Map
Cloudflare AI applications usually combine several products. Keep the model call, provider control plane, retrieval index, and app state as separate decisions.
| Product | Role | Use it when |
|---|---|---|
| Workers AI | Cloudflare-hosted model inference through Worker bindings. | You need text generation, embeddings, classification, speech, image, or other model tasks close to your Worker code. |
| AI Gateway | Routing, observability, and policy controls for model providers. | You need provider access, analytics, logs, caching, retries, fallback, rate limiting, or spend controls across Workers AI and external providers. |
| Vectorize | Vector database for embeddings and similarity search. | You need semantic search, recommendations, memory, or RAG retrieval over your own content. |
| D1 / R2 / KV / Durable Objects | Storage and state companions, not model products. | You need to persist documents, metadata, assets, sessions, cache entries, coordination state, or per-user/per-tenant data around an AI workflow. |
How The Pieces Fit
Workers AI is the inference layer. In a Worker, call a model through a Workers AI binding when Cloudflare-hosted inference is the right fit and the application logic lives in Workers.
AI Gateway sits in front of model providers. Use it when the hard part is controlling requests: routing traffic, switching providers, observing usage, adding caching, retrying failed requests, or enforcing limits. It can cover Workers AI as well as external providers, so it is the control plane rather than the model runtime itself.
Vectorize is the retrieval layer. Store embeddings generated by Workers AI or another embedding provider, then query the index to find semantically related content. For RAG, Vectorize returns the relevant references; a model still generates the final response.
D1, R2, KV, and Durable Objects are the app data layer around the AI system:
Use D1 for relational metadata, user records, job rows, and audit trails.
Use R2 for source documents, images, exports, and other large artifacts.
Use KV for read-heavy configuration, prompt snippets, cache keys, and lightweight lookup data.
Use Durable Objects for strongly consistent coordination, WebSockets, shared room state, or per-conversation state that must not split across requests.
Common Architectures
| Goal | Typical shape |
|---|---|
| Simple model call | Worker + Workers AI binding. Add AI Gateway when you need logs, caching, fallback, or provider controls. |
| Streaming chat | Worker receives the request, calls Workers AI, and streams the result back to the client. |
| RAG answer | Worker loads source content from storage, embeds or queries with Vectorize, then sends retrieved context to a model. |
| Webhook bot | Worker acknowledges the webhook quickly, does longer work with ctx.waitUntil(), stores state in D1/KV/Durable Objects, and calls AI only when the bot behavior needs it. |
Guides
Workers AI Models and Pricing -- practical model categories, a curated text-generation table, and cost calculation notes.
Chat Memory and RAG -- a request-boundary and storage guide for chat history, prompt assembly, and retrieval.
Resilient AI Routes -- a same-shape fallback pattern for guarding AI calls against budget limits, timeouts, and bad output.
Recipes
Workers AI Streaming SSE Proxy -- a concrete Workers AI streaming pattern with abort handling and a runtime kill switch.
Bot Worker Pattern -- a webhook-driven Worker pattern that composes well with AI calls and state storage.
Keep This Page Stable
Do not copy pricing tables or the full model catalog here. Treat this page as the durable product map, then check the official Cloudflare docs when choosing exact models, providers, limits, or pricing.