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

Gate in Gate on each exit Who acts people and agents Access checks who is acting Where the AI runs isolated session or your own app Models AI Gateway Tools MCP server portal Private systems Mesh or Tunnel routes Evidence every model call, tool call and connection is logged with the user and the policy At the edge, outside your session Case A Prompts in AI Security for Apps Case C Staff use AI apps Gateway, CASB, DLP Case D AI crawlers AI Crawl Control
The same shape for every setup: one gate in front of the session and one on every exit. The row at the bottom covers what comes in from outside.

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.

BuildingAdopting Your customers use itYour staff use it Your staff use the toolsBots visit your sites Are you building AI, or adopting AI that someone else built? Who uses what you build? your customers, or your staff and operations Who is exposed? your staff using SaaS AI, or your own sites A. AI in your product Public AI endpoints, prompts from the internet AI Security for Apps, WAF, Bots, AI Gateway Build it with Part B B. Internal AI you build Copilots, agents, engineering and IT automation Access, AI Gateway, MCP portal, DLP, Mesh or Tunnel Cloudflare OS (A6) or Part B C. Your staff use third-party AI ChatGPT, Claude, Gemini, Copilot, coding assistants Shadow IT, Gateway policies, DLP, CASB No building involved D. AI visits your sites Crawlers and agents reading content and calling APIs AI Crawl Control, Bots No building involved Calling a hosted model API from your own product is still A: you build, the model is hosted. Where the model runs is decided in A3.
The four cases. A product that calls a hosted model API is still case A, because you build the product. A3 covers where the model runs.
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.

Model callsTool callsPrompts inStaff use AIAI visitorsWhat do you want to control?C1 AI Gatewaylogs, limits, fallback,guardrails and DLP oncalls to modelsC2 MCP portalschoose which toolsagents may use,log every callC3 AI Security for Appsfinds prompt injection,PII and unsafe topicsin your AI endpointsC4 Gateway + DLPShadow IT, CASB, DLP:see staff use of AI apps,block or limit actionsC5 AI Crawl Controlsee AI crawlers,allow or blockeach one
Pick what you want to control. The table below has the details.
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.
Employees, IDEs, coding agents, internal apps Your customers and their apps Staff using SaaS AI AI crawlers and agents Identity Access, your IdP, device posture Gateway + One Client Tool traffic MCP server portals tools per portal, aliases, Code Mode, Access logs optional Gateway route Model traffic AI Gateway logs, cache, rate limits, fallback, guardrails, DLP all plans Prompts in AI Security for Apps prompt injection, PII, unsafe topics, in WAF rules Enterprise add-on Staff using SaaS AI Gateway, Shadow IT, CASB see usage, block or limit actions, scan prompts DLP: Enterprise add-on AI visitors AI Crawl Control, Bots see, allow or block per crawler all plans DLP profiles: one detection engine for AI Gateway, HTTP traffic, SaaS files and AI prompts Where the agent or tool code runs Workers + Agents SDKThink, AIChatAgent (Part B) Dynamic Workersgenerated code, Code Mode SandboxesLinux microVM or Dynamic Worker Containersany runtime, heavy work Browser Runsites without an API Reaching private systems Cloudflare Tunnelpublish specific apps Cloudflare Meshprivate IPs, both directions Workers VPC (beta)Worker to private service Logs and evidenceLogpush to your SIEM, AI Gateway logs,Access and Gateway logs Models Workers AI (binding, no API key) Hosted providers through AI Gateway Private inference on hardware you own (A3) Detections in AI Security for Apps need the WAF on the zone and an Enterprise add-on. DLP is an add-on to Zero Trust Enterprise.
Control map for AI traffic: what each control sits in front of.

Sandboxes and Code Mode keep agent-written code away from your credentials.

AI security on Cloudflare: one identity from login to tool call Sandboxes and Code Mode keep agent-written code away from your credentials. Cloudflare You or third party Identity Isolation Models OpenAI, Anthropic, Google Workers AI Your own models Employee or agent Cloudflare One Client (optional) Unattended agent: service token Shadow AI visibility Shadow IT dashboard, CASB Your identity provider Entra ID, Okta, Google one login for everything Secure Web Gateway DLP on prompts CLOUDFLARE AI Gateway logs and budgets per user guardrails and DLP on prompts provider keys stored here fallback and caching ID Local AI apps MCP clients on the laptop Claude Code, opencode Codex, Claude Desktop Other MCP clients CLOUDFLARE Agent runs on Cloudflare optional: nothing runs on the laptop Cloudflare OS workspace Coding agent in a sandbox Worker holds the keys, limits egress CLOUDFLARE runs on Cloudflare Workers Cloudflare Access (ZTNA) identity on every request ID MCP server portal one endpoint for all tools only the tools you approve every call logged ID Code Mode The model writes JavaScript instead of calling dozens of tools one by one. search tools execute code Dynamic Worker isolated sandbox no credentials inside no open internet calls tools by name Secure Web Gateway (optional) DLP and HTTP logs Remote MCP servers yours, protected by Access sign-in ID Tunnel or Mesh private servers and hosts Internal services Data warehouse Internal APIs Tickets and code Hosts and firewalls on your private network SaaS MCP servers Slack Jira GitHub Salesforce each user signs in with their own account Your SIEM Logpush: Access, Gateway, AI Gateway or HTTPS ID OAuth per user ID SSO login Access token Sign in Your IdP signs people in (SSO). Agents use service tokens. Check Access checks identity with your policies. Model calls AI Gateway adds the verified user ID to each model call. Tools The portal offers only the servers and tools you approve. Systems OAuth servers ask each user to sign in with their own login. Evidence Access, Gateway and AI Gateway log who did what, sent to SIEM. Sources: Cloudflare docs for AI Gateway, MCP server portals, Access, Gateway, CASB, Logpush, Sandboxes (coding agents), Dynamic Workers, Tunnel, Mesh, Cloudflare OS.
AI security on Cloudflare: one identity from login to tool call.

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.

NoYesYesNoMust the data stay insideyour company network?Do you need models fromOpenAI, Anthropic or Google?I2 Hosted providersthrough AI Gateway:one place for logs,limits and fallbackI1 Workers AImodels on Cloudflare,no API keys,the simplest startI3 Private inferenceyour own machines,reached over Mesh,data stays on your networkYou can combine them: use I2 for general work and I3 for sensitive work.
Select where the model runs.
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.

Agent or appone endpoint AI Gateway identity, budgets, logsguardrails, DLPsame policy for every route Routerpicks the route Hosted providerdefault for general work, or fallback whenprivate capacity is busy Mesh + Zero Trustprivate route, scopedby policy Private nodeidle Mac or GPU boxserves the model general work sensitive work
A local inference mesh behind one gateway.

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.

Who Engineer orops personbrowser only Triggers: ticket,PR, schedule Gate 1 Access your IdP,one sessionidentity,deviceposture Session in your tenancy Agent harnessloop, memory, sub-agentsThink, AIChatAgent, own loopor a coding agent (Part B) Workspacerepo, spec, tests, skillskept in the session, not on the laptop Isolationcontainer or Sandbox,destroyed on exit Code Mode, Dynamic Workersgenerated code runs in anisolate with no ambient rights Gate 2: every exit AI Gatewaymodel calls, DLP,guardrails, attribution MCP portaltools scoped per role,Code Mode, logs Zero Trust routesMesh or Tunnel, only whatthe group may reach Git, CI, reviewbranch protection, reviewagents, human approval Targets Modelshosted, Workers AI,private mesh (A3) MCP serversinternal and SaaS Hosts, databases,firewallsapproved targets Main branch,deploya human merges direct call to a provider: denied can be blocked with a Gateway policy Evidence: who reached what, when and under which policy, logged to your own SIEM (Logpush)
A governed agent workspace: one gate in, one gate 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.

YesNoYesNoYesNoYesNoDoes the agent mainly call many toolsor one large API?E1 Code Modethe model writes one piece of codethat calls your tools(experimental)Does it need to read websitesthat have no API?E5 Browser Runheadless Chrome reads anduses the website for the agentDoes it run code you do not trust,written in JavaScript?E2 Dynamic Workersisolated JavaScript, created on demandyou control network and accessDoes it need a shell, code repos,package installs or tests?E3 Sandboxesa Linux microVM or a Dynamic Workerfor shell, repos and test runsE4 Containersyour own heavy workload, a specific runtimeor an existing container image
Select where agent-written code runs.
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.

Staff workspaceEngineering agentsCustomer AIExisting toolsWhat do you need?A6 Cloudflare OSa workspace for all staff:agent chat, documents,small apps, workflowsA4 Governed workspaceagents for engineers:shell, repos and tests,under your rulesB Build it yourselfAI for your customers:you build the agentyourselfH Secure what is theregovern the agents andtools your staff alreadyuse (option H)
Select what you need: Cloudflare OS or another path.
  • 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:

  1. The user describes the app. The agent asks structured questions when the request leaves something open.
  2. The agent plans, edits files, deploys a preview, reads the browser console, repairs errors and repeats, while the user follows along.
  3. 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.