AutoRAG takes the plumbing out of RAG on Cloudflare
Cloudflare has launched AutoRAG in open beta: a fully managed Retrieval-Augmented Generation (RAG) pipeline built on the company’s own developer platform. The service is designed to handle everything from data ingestion and embedding to vector storage, semantic retrieval, and LLM response generation—eliminating the need to stitch together those pieces manually.
RAG itself exists because LLMs only know what they were trained on. They struggle with new, proprietary, or domain-specific data, and the common workarounds have real costs: stuffing context into system prompts bloats input size and hits context-window limits, while fine-tuning is expensive and needs constant retraining. RAG answers this by pulling relevant content from your own data source at query time, feeding it together with the user’s question into an LLM for a grounded response. That makes it a natural fit for support bots, internal knowledge assistants, and semantic search over evolving documentation.
With AutoRAG, you skip the glue code. You create an instance, point it at a data source such as an R2 bucket, and Cloudflare handles the pipeline—indexing content in the background, storing vectors in Vectorize, and serving queries through Workers AI.
How the pipeline works
AutoRAG runs on two processes: indexing and querying.
Indexing is asynchronous. It starts when you create an AutoRAG instance and continues in cycles, reprocessing new or updated files after each job finishes. The flow is:
- File ingestion: reads files directly from your data source. R2 is supported today for documents like PDFs, images, text, HTML, and CSV.
- Markdown conversion: uses Workers AI’s Markdown Conversion to normalize all files into structured Markdown. For images, Workers AI performs object detection followed by vision-to-language transformation to produce Markdown text.
- Chunking: splits the extracted text into smaller pieces for finer retrieval granularity.
- Embedding: converts each chunk into vectors using Workers AI’s embedding model.
- Vector storage: stores vectors plus metadata—like source location and file name—in a Vectorize database created on your account.
Querying is synchronous and triggers on a search request to either the AutoRAG AI Search or Search endpoint. AutoRAG then orchestrates:
- Query rewriting (optional): rewrites the input query with a Workers AI LLM to improve retrieval quality.
- Embedding: converts the rewritten (or original) query to a vector using the same embedding model applied to your data.
- Vector search: searches the query vector against the AutoRAG’s Vectorize database.
- Content retrieval: pulls the most relevant chunks with their metadata, retrieving the original content from the R2 bucket.
- Response generation: passes the retrieved content and the user’s query to a Workers AI text-generation model to produce the final answer.
Getting your content in: a five-minute tutorial
The simplest path to AutoRAG is pointing it at an existing R2 bucket. But if your content is still on a webpage, or requires a frontend to render first, you can use the Browser Rendering API, which is now generally available. It offers endpoints for extracting HTML, capturing screenshots, and generating PDFs, with a crawl endpoint coming soon.
This walkthrough uses a Cloudflare Worker with Puppeteer to render web pages in a headless browser, upload the content to R2, and hook it into AutoRAG for semantic search and Q&A.
Step 1: Create a Worker to fetch pages and upload to R2
Create a new Worker project named browser-r2-worker:
npm create cloudflare@latest -- browser-r2-worker
Choose the following setup options:
- Start with the Hello World starter.
- Use the Worker only template.
- Write in TypeScript.
Install @cloudflare/puppeteer to control the Browser Rendering instance:
npm i @cloudflare/puppeteer
Create an R2 bucket named html-bucket:
npx wrangler r2 bucket create html-bucket
Add browser rendering and the R2 bucket bindings to your Wrangler configuration:
{
"compatibility_flags": ["nodejs_compat"],
"browser": {
"binding": "MY_BROWSER"
},
"r2_buckets": [
{
"binding": "HTML_BUCKET",
"bucket_name": "html-bucket",
}
],
}
Replace src/index.ts with the skeleton script:
import puppeteer from "@cloudflare/puppeteer";
// Define our environment bindings
interface Env {
MY_BROWSER: any;
HTML_BUCKET: R2Bucket;
}
// Define request body structure
interface RequestBody {
url: string;
}
export default {
async fetch(request: Request, env: Env): Promise<Response> {
// Only accept POST requests
if (request.method !== 'POST') {
return new Response('Please send a POST request with a target URL', { status: 405 });
}
// Get URL from request body
const body = await request.json() as RequestBody;
// Note: Only use this parser for websites you own
const targetUrl = new URL(body.url);
// Launch browser and create new page
const browser = await puppeteer.launch(env.MY_BROWSER);
const page = await browser.newPage();
// Navigate to the page and fetch its html
await page.goto(targetUrl.href);
const htmlPage = await page.content();
// Create filename and store in R2
const key = targetUrl.hostname + '_' + Date.now() + '.html';
await env.HTML_BUCKET.put(key, htmlPage);
// Close browser
await browser.close();
// Return success response
return new Response(JSON.stringify({
success: true,
message: 'Page rendered and stored successfully',
key: key
}), {
headers: { 'Content-Type': 'application/json' }
});
}
} satisfies ExportedHandler<Env>;
Deploy the Worker:
npx wrangler deploy
Test it with a cURL request that fetches a page’s HTML and uploads it to the bucket:
curl -X POST https://browser-r2-worker.<YOUR_SUBDOMAIN>.workers.dev \
-H "Content-Type: application/json" \
-d '{"url": "https://blog.cloudflare.com/introducing-autorag-on-cloudflare"}'
Step 2: Create your AutoRAG and watch the indexing
Once your bucket has content, go to the Cloudflare dashboard, navigate to AI > AutoRAG, and select Create AutoRAG. During setup:
- Select the R2 bucket holding your knowledge base (
html-bucketin this case). - Choose an embedding model—the Default is recommended.
- Choose an LLM for response generation—the Default is recommended.
- Select or create an AI Gateway to monitor model usage.
- Name your AutoRAG (e.g.,
my-rag). - Select or create a Service API token so AutoRAG can access your account’s resources.
Hit Create. AutoRAG automatically provisions a Vectorize database and starts indexing. You can monitor progress on the instance’s Overview page; indexing time depends on the number and type of files in the source.

Step 3: Test and integrate
After indexing completes, open your AutoRAG’s Playground tab and ask a question based on your content—for example, “What is AutoRAG?”
To wire AutoRAG into your own application, use the AI binding in a Worker:
{
"ai": {
"binding": "AI"
}
}
Call the aiSearch() method to get an AI-generated answer. Alternatively, use Search() to retrieve results without a generated response.
const answer = await env.AI.autorag('my-rag').aiSearch({
query: 'What is AutoRAG?'
});
For full integration instructions, open your AutoRAG and navigate to Use AutoRAG.
Pricing, limits, and roadmap
AutoRAG is free to enable during the open beta. It runs on Cloudflare resources provisioned within your own account, billed as standard usage:
- R2: stores your source data.
- Vectorize: stores embeddings and powers semantic retrieval.
- Workers AI: converts images to Markdown, generates embeddings, rewrites queries, and produces responses.
- AI Gateway: tracks and controls model usage.
Beta limits are 10 AutoRAG instances per account and 100,000 files per AutoRAG.
On the roadmap for 2025: additional data source integrations beyond R2, including direct website URL parsing via browser rendering and structured sources like Cloudflare D1, plus built-in reranking and recursive chunking to improve answer quality.



