Cloudflare just made it easier to add AI-powered search to your product stack. Here’s a practical playbook to ship a fast, reliable RAG search on Cloudflare’s edge.
The idea: simple, fast AI search on the edge
Instead of stitching multiple clouds, you can run retrieval and generation close to users. Use Workers for routing, Vectorize for embeddings search, and Workers AI for LLM calls.
Build plan (90‑minute RAG)
- Collect sources: docs, FAQs, site content, product manuals. Clean text (strip HTML, normalize whitespace).
- Chunk content: 500–800 tokens per chunk with overlap (50–100 tokens) to preserve context.
- Embed chunks: create vector embeddings with a consistent model. Store vectors + metadata (title, URL, tags, timestamp) in Vectorize.
- Serve a /search endpoint on Workers: accept query, create query embedding, retrieve top-k chunks with filters (e.g., product, locale, version).
- Optional rerank: use a lightweight reranker or cross-encoder to tighten top results before generation.
- Generate the answer: prompt an LLM in Workers AI with retrieved context. Return citations, snippets, and confidence signals.
- Cache & observe: cache popular queries; log retrieval hits, latency, token use, and answer quality.
Reference architecture
Ingest → Chunk → Embed (Workers AI) → Store (Vectorize + metadata store) → Query embed → Vector retrieval → (Rerank) → LLM answer with citations.
Design tips that matter
- Hybrid search wins: combine keyword filters with vector similarity for relevance and control.
- Ground with metadata: keep source URL, section headers, and timestamps for trustworthy answers.
- Tune chunks: too small loses context; too big bloats tokens. Start at 600–700 tokens.
- Rerank cheaply: rerank 10–20 candidates; it often beats retrieving more.
- Cache wisely: cache final answers and retrieved IDs per normalized query; invalidate when sources update.
- Evaluate continuously: keep a small, labeled question set. Track precision@k and answer helpfulness.
- Guardrails: rate-limit, require auth for internal indexes, and display source citations by default.
What to run where
- Workers: API routing, auth, input validation, caching, and logging.
- Vectorize: similarity search with metadata filters for fast retrieval.
- Workers AI: embeddings + LLM generation close to users for low latency.
- KV/Durable Objects/D1: store doc metadata, indexing state, and query analytics.
Costs and performance
- Reduce hops: keep embeddings, retrieval, and generation on the same edge to cut latency.
- Batch operations: embed documents in batches and stream answers to improve UX.
- Control token spend: cap context length, trim redundant chunks, and summarize long sources offline.
Great fits for edge AI search
- Public docs and changelogs that update frequently.
- Support portals where speed and accuracy drive deflection.
- Product catalogs with attributes and filters.
- Internal handbooks and runbooks with strict access controls.
Source
Cloudflare details how they’re simplifying AI search on their edge stack in their announcement: Cloudflare Blog.
Takeaway
You don’t need a complex MLOps pipeline to ship helpful AI search. Keep retrieval, reranking, and generation on the edge, attach citations, and measure relevance.
Get more like this
If you found this useful, subscribe for weekly, no-fluff AI build guides and case studies: The AI Nuggets Newsletter.

