Step 1: choose your path
Cloudflare and AI: choose your path
Four kinds of AI question, the Cloudflare products for each, and where models and agent code run. Every claim links to the docs.
Most conversations about AI and Cloudflare start with a product name. It helps to start with the shape of the setup. Then you can see which parts your case needs and which Cloudflare product covers each one.
The shape of every AI setup
Someone acts, and Access checks who it is. The AI runs in an isolated session or in your own app. From there it reaches models, tools and private systems, and each exit gets one gate. Every model call, tool call and connection is logged with the user and the policy.
Three things sit at the edge of this picture: prompts that arrive from the internet, staff who use AI apps you did not build, and AI crawlers that read your sites. The four cases below differ in which of these parts you have to deal with.
A1. Step 1: what kind of AI question is this?
Two questions sort your situation into four cases: do you build AI yourself or use AI that someone else built, and who is affected, your customers or your employees. Each case lists the Cloudflare products to put in place, in order.
| Case | What the customer says | Put in place, in this order | Then |
|---|---|---|---|
| A. AI in your product | "We added a chatbot or AI search to our app." "We worry about prompt injection and PII in prompts." | 1. Find the AI endpoints (LLM endpoint discovery). 2. AI Security for Apps detections in WAF rules. 3. AI Gateway between app and model for logs, limits and fallback. 4. Normal WAF, Bots and API protection. | Build with Part B or a plain Worker. If users should build apps inside your product: VibeSDK (A7). |
| B. Internal AI you build | "We want agents for our engineers and IT." "Our staff need an assistant on our data." | 1. Access in front, with your identity provider. 2. All model calls through AI Gateway. 3. Tools through an MCP server portal. 4. DLP. 5. Private reach over Tunnel, Mesh or Workers VPC. 6. Isolated execution. | A ready-made start: Cloudflare OS (A6), or VibeSDK if staff should build apps (A7). Or build: Part B for the agent, A4 for the governed workspace pattern. |
| C. Staff use third-party AI | "People paste code and customer data into ChatGPT." "We cannot see which AI tools are used." | 1. Shadow IT dashboard and CASB for visibility. 2. Gateway HTTP policies, including actions inside AI apps. 3. DLP profiles on prompts and uploads. 4. Sanctioned tools behind Access. | Nothing to build. Offer a sanctioned path. |
| D. AI visits your sites | "AI crawlers take our content." "Agents hit our APIs." | 1. AI Crawl Control: see which AI services access your content. 2. Allow or block per crawler, check robots.txt compliance. 3. Bots and rate limiting for the rest. | Optional: pay per crawl (private beta). |
A2. The control map: which product guards which traffic
The picture above shows where each control sits. Calls to models go through AI Gateway and calls to tools through MCP server portals. AI Security for Apps checks prompts from the internet, Gateway, CASB and DLP cover staff who use AI apps, and AI Crawl Control covers AI crawlers. Access checks who is acting, and DLP and logs apply to all of them.
| Control | Guards | Key facts from the docs | Watch out |
|---|---|---|---|
| C1. AI Gateway | Calls from apps and agents to model providers. | A proxy with analytics, logging, caching, rate limiting, retry and model fallback. Available on all plans. Guardrails evaluate prompts and responses and can flag or block by category. DLP scans prompts and responses without Gateway HTTP filtering or TLS decryption. | It covers only traffic you route through it. To force that, also block direct provider endpoints. |
| C2. MCP server portals | Tool calls from MCP clients to internal and SaaS MCP servers. | One endpoint for many servers. Admins choose tools and prompts per portal, rename them with aliases, and can enable Code Mode (two tools, JavaScript run in a Dynamic Worker). Access logs each tool request. Private servers work through Tunnel with Gateway routing turned on. | Independent MFA, purpose justification and temporary authentication are not enforced for servers authorized through a portal. Blocked users can still reach a server by its direct URL unless Access is its OAuth provider. |
| C3. AI Security for Apps | Prompts sent from the internet to your own LLM-backed endpoints. | Model-agnostic. Detects prompt injection, PII and unsafe or custom topics in requests to endpoints labeled cf-llm, JSON only. Results become WAF fields for custom or rate limiting rules. LLM endpoint discovery is on all plans. |
The detection fields and log mode ruleset are a paid add-on on Enterprise. Formerly called Firewall for AI. |
| C4. Gateway, Shadow IT, CASB, DLP | Employees using third-party AI apps. | The holistic AI security learning path names the Shadow IT dashboard and API CASB for visibility, Gateway policies to allow, block or redirect, and DLP for data loss. HTTP policies can control specific actions inside AI apps. CASB has API integrations for ChatGPT, Claude and Gemini (changelog, August 2025). | HTTP policies need the Cloudflare root certificate or a custom certificate on the device. DLP is an add-on to Zero Trust Enterprise. |
| C5. AI Crawl Control and Bots | AI services reading your content. | A dashboard of crawler activity, allow or block per crawler, robots.txt compliance and enforcement rules. All plans. Formerly AI Audit. | Pay per crawl is in private beta. |
Sandboxes and Code Mode keep agent-written code away from your credentials.
A3. Where does inference run?
Where the model runs decides where your data goes, what it costs and who operates it. AI Gateway and Access work with all three options.
| Option | Use when | Data boundary | You operate |
|---|---|---|---|
| I1. Workers AI | You want models without API keys, billed on Cloudflare, called through the AI binding. | Stays on Cloudflare. | Nothing. |
| I2. Hosted providers through AI Gateway | You need frontier models from OpenAI, Anthropic, Google and others, with one place for logs, limits and fallback. | Prompts go to the provider, with gateway guardrails and DLP in between. | Provider keys and routing rules. |
| I3. Private inference on hardware you own | Some work must not leave the company boundary, or you want to use idle machines as low-cost capacity. | Prompts stay on your network, reached over private routes. | The machines, model serving and capacity. |
The idea of a local inference mesh
Your company may own idle computers: developer Macs, GPU workstations, spare servers. A mesh can join them into one pool of private model capacity. Agents call one controlled entry point, and a router picks where each request runs. Sensitive work runs on the private nodes, so sensitive prompts never leave the company network. Idle hardware takes over part of the work that would otherwise go to hosted models. Hosted providers stay as the default or fallback, so a busy mesh does not stop work.
Three Cloudflare pieces make it governable:
- AI Gateway is the front door. It applies identity, budgets, guardrails, DLP and logs to every route, private or hosted.
- Cloudflare Mesh gives each enrolled server or laptop a private Mesh IP and lets nodes advertise routes. Zero Trust policy decides who can reach which node.
- AI Gateway custom providers connect models that have an HTTPS API endpoint, including self-hosted models, so the same logs, limits and guardrails apply.
I do not cover how the gateway reaches the private machines (Mesh, Tunnel or Workers VPC, which is in beta). Check the network path for your setup.
A4. Internal IT and engineering: the governed agent workspace
This is the shape from the start of this part, built out for case B. Engineers and operations staff work with AI agents that change code and infrastructure, under rules your company sets. It combines the controls from A2 around one session, with one gate in front and one on every exit.
Your engineers may already use agents. Without a sanctioned path they use personal keys and tools, and central IT has no log, budget or policy. A governed workspace sets identity, model access, tool access and network reach once, not per laptop and per tool. An agent that patches servers or changes a firewall needs a limited route and an approved plan. Changes go through your own git, CI and branch protection, and a person approves the merge or the change.
| Element | What it does | Built from | Docs |
|---|---|---|---|
| Session entry | The user signs in through your IdP. A browser session means nothing is installed on the laptop. | Access in front of the workspace, with device posture checks. | Access |
| Isolation | Each session runs in an isolated environment in your own account, removed on exit. | Sandboxes (a Container, which is a Linux microVM, or a Dynamic Worker) or Containers. | Sandboxes |
| Agent harness | Runs the loop, keeps memory, delegates to sub-agents. | Think, AIChatAgent or your own loop (Part B), or an existing coding agent. | Agents |
| Model access | Model calls go through the gateway. Provider keys are stored in the gateway, prompts are scanned, and each request carries the verified Access user ID. | AI Gateway behind Access, stored keys, guardrails and DLP. Gateway policies can block direct provider endpoints. | AI Gateway with Access, stored keys |
| Tools | Agents get only the tools their role allows. Large tool sets collapse into a code tool. | MCP server portals with per-portal tools and Code Mode. | MCP server portals |
| Reach | Internal hosts, databases and control planes are reachable only on routes the user's group is allowed. | Zero Trust client with private routes over Mesh or Tunnel. | Mesh |
| Change control | Changes flow through git, CI and branch protection, then reviewer agents, then a human approval. | Your own git and CI. | Not a Cloudflare product |
| Evidence | Every model call, tool call and connection is logged with user and policy. | AI Gateway logs, Access and Gateway logs, Logpush to a SIEM. | AI Gateway Logpush, Zero Trust logs |
| Private inference | Optional private model capacity on idle machines, behind the same gateway. | AI Gateway custom providers plus a private route (Mesh), see A3. | Custom providers |
The harness is a Part B decision. Think suits a stateful chat or operations agent. AIChatAgent or your own loop suit cases where you must control the model call. Patch rollouts and reviews are long tasks that must survive restarts, so a Workflow fits the approved, repeatable part: rollout in batches, rescan, close the ticket.
Each gate protects only what passes through it. To control model egress, also block the direct provider endpoints. Start read-only for infrastructure agents and give write access per task, behind an approval step. Keep the human merge and the human approval of infrastructure plans.
A5. Where does agent-written code run? The execution ladder
When an agent writes and runs code, use the lightest environment that does the job.
| Step | Use when | What it is | Watch out |
|---|---|---|---|
| E1. Code Mode | The agent has many tools, or an API with many operations, and loses context to tool definitions. | The model gets one code tool and writes JavaScript that calls typed tool methods. In MCP server portals it replaces all upstream tools with a search tool and an execute tool. | Experimental and may introduce breaking changes. |
| E2. Dynamic Workers | You must run code you do not trust, written at runtime. | Isolated Workers created on demand. You control their bindings and whether they reach the network. A lightweight alternative to containers. | Runs JavaScript, WebAssembly and (with a compatibility flag) Python. It has no Linux shell. Open beta since March 2026 on Workers Paid. Check the current status. |
| E3. Sandboxes | The agent needs a shell, repos, package installs or test runners. | An isolated place to run code, either a Container (a Linux microVM) or a Dynamic Worker, reached through your Worker. Your Worker decides what data and APIs the code gets and whether it reaches the Internet. | Workers Paid plan. The docs list separate Sandbox SDK versions. Check which one you use. |
| E4. Containers | A workload needs many CPU cores, lots of memory, a specific runtime or an existing container image. | Serverless containers started and controlled by a Worker. | Use them directly for your own workloads. As a sandbox, a Container is the Linux option. |
| E5. Browser Run | The target is a website without an API. | Headless Chrome on the Cloudflare network (formerly Browser Rendering): markdown, screenshots, PDFs, scripted interaction. | Treat fetched page content as untrusted input to the model. |
A6. A ready-made start: Cloudflare OS
Cloudflare OS is an open-source agent workspace for everyone in a company, including people who do not code. You deploy it into your own Cloudflare account and adapt it. It is case B as a finished starting point, with four parts.
- Agent workspace. Each person works in the browser with an agent that knows your company context and shared skills. The agent writes and runs code in an isolated runtime.
- Gadgets. The agent can build small apps for one person or one team. Each app runs in its own Dynamic Worker with its own database and can be shared like a document.
- Gatekeepers. A Gatekeeper sits between the workspace and one external service. It limits access to the resource you chose, logs every action and asks a person to approve actions with side effects.
- Workflows. Repeatable jobs run on demand, on a schedule or when an event happens in a connected system.
| Control | What Cloudflare OS does | Matches in this guide |
|---|---|---|
| Identity | Cloudflare Access controls who can enter. Inside, every agent and app starts with access to nothing and asks for each resource. | A2, identity |
| Model calls | Every inference call runs through AI Gateway, attributed to a person, team or workspace, with budgets and rate limits. Any model can be used, including self-hosted ones. | C1, I1 to I3 |
| Tool calls | Gatekeepers give scoped access to single resources. Existing MCP servers connect through MCP server portals. | C2 |
| What the agent has seen | The platform records which resources agents observed. It uses this to decide who may open the workspace or see its output, and when an agent may send data out. | Not covered by the other controls |
| Code execution | The agent works by writing code. Server code runs in a Dynamic Worker with outbound internet disabled. Client code runs in a sandboxed frame. | E1, E2 |
| Not covered in the public sources | DLP, private network reach over Mesh or Tunnel, and export of logs to a SIEM. Plan these with the controls in A2. | C4, A4 |
It fits a workspace for all staff, including people who do not code, with shared skills and company context for every agent and small internal apps that people build and change themselves.
It is early access, and the README says it still has "many rough edges". Running it on your own servers with workerd is listed as "coming soon". A managed version in the Cloudflare dashboard, containers for development workflows and Slack support are planned. For customer-facing AI or shell-heavy engineering agents, see Part B and A4.
See also the GitHub repository and os.cloudflare.app.
A7. Another ready-made start: VibeSDK
VibeSDK is an open-source (MIT) platform where people build and deploy full-stack apps by describing them to an AI coding agent. The README calls it "an open-source vibe coding platform that helps you build your own vibe-coding platform". It is a starting point for case A (your customers build apps inside your product) or case B (internal teams such as marketing, product and support build their own tools, as the launch post describes it).
According to the README, a session works like this:
- The user describes the app. The agent asks structured questions when the request leaves something open.
- The agent plans, edits files, deploys a preview, reads the browser console, repairs errors and repeats, while the user follows along.
- Each project has its own workspace and version history with restore points. The finished project can be exported to continue elsewhere.
| Part | What it does | Docs |
|---|---|---|
| Think agent | Runs the model-and-tool loop. It uses explicit tools to read and edit the workspace, deploy previews and inspect browser logs. Bash access is disabled. | Think |
| Workspace | A Durable Object per project holds the files. | Durable Objects |
| Previews | Generated code is bundled and loaded as a Dynamic Worker, with no long-running development server. | Dynamic Workers |
| App data | Each generated app has isolated SQLite storage in a Durable Object Facet. | Durable Objects |
| Version history | Cloudflare Artifacts stores git history and restore points. It is an optional setting in the README. | Artifacts |
| Model calls | Configured providers are routed through AI Gateway, with observability and caching. | AI Gateway |
| Control | What VibeSDK does | Matches in this guide |
|---|---|---|
| Model calls | Routed through AI Gateway, with observability and caching. | C1, I2 |
| Code execution | Previews run as Dynamic Workers. The agent has no bash access to the workspace. | E2 |
| Isolation | Each project has its own agent, workspace, repository and app storage. Preview URLs are signed and limited to one branch. | A4 |
| Identity | Authentication providers are optional and configuration-dependent. The README does not describe Access. | A2, identity |
| Not covered in the README | DLP, Gateway policies for staff, private reach over Mesh or Tunnel, and export of logs to a SIEM. Plan these with the controls in A2. | C4, A4 |
It fits a platform where people who do not write code build small apps, a SaaS product that lets customers build their own customisations, or a base that you fork and change. It builds and hosts apps. To govern the coding agents your engineers already use, see A4. Cloudflare OS gives each person an agent workspace, while VibeSDK turns descriptions into deployed apps.
The reference architecture calls it a starter template, and I found no support or maturity statement for VibeSDK itself in the README. It builds on features that are still maturing: Think is experimental, Dynamic Workers entered open beta in March 2026, and Artifacts is in open beta (changelog, 1 October 2026). For production, the README lists a Workers Paid plan, Workers for Platforms access for production previews, a custom domain with wildcard DNS (and Advanced Certificate Manager where the layout needs it), and credentials for at least one model provider. The September 2025 launch post describes an earlier design with Sandboxes and Workers for Platforms. The README describes the current design.
See also the setup guide and the demo.