All skills
Skillintermediate

Cloudflare AI Search Reference

Expert guidance for implementing Cloudflare AI Search (formerly AutoRAG), Cloudflare's managed semantic search and RAG service.

Claude Code Knowledge Pack7/10/2026

Overview

Cloudflare AI Search Reference

Expert guidance for implementing Cloudflare AI Search (formerly AutoRAG), Cloudflare's managed semantic search and RAG service.

Overview

AI Search is a managed RAG (Retrieval-Augmented Generation) pipeline that combines:

  • Automatic semantic indexing of your content
  • Vector similarity search
  • Built-in LLM generation

Key value propositions:

  • Zero vector management - No manual embedding, indexing, or storage
  • Auto-indexing - Content automatically re-indexed every 6 hours
  • Built-in generation - Optional AI response generation from retrieved context
  • Multi-source - Index from R2 buckets or website crawls

Data source options:

  • R2 bucket - Index files from Cloudflare R2 (supports MD, TXT, HTML, PDF, DOC, CSV, JSON)
  • Website - Crawl and index website content (requires Cloudflare-hosted domain)

Indexing lifecycle:

  • Automatic 6-hour refresh cycle
  • Manual "Force Sync" available (30s rate limit)
  • Not designed for real-time updates

Quick Start

1. Create AI Search instance in dashboard:

  • Go to Cloudflare Dashboard → AI Search → Create
  • Choose data source (R2 or website)
  • Configure instance name and settings

2. Configure Worker:

// wrangler.jsonc
{
  "ai": {
    "binding": "AI"
  }
}

3. Use in Worker:


  async fetch(request, env) {
    const answer = await env.AI.autorag("my-search-instance").aiSearch({
      query: "How do I configure caching?",
      model: "@cf/meta/llama-3.3-70b-instruct-fp8-fast"
    });
    
    return Response.json({ answer: answer.response });
  }
};

When to Use AI Search

AI Search vs Vectorize

FactorAI SearchVectorize
ManagementFully managedManual embedding + indexing
Use whenWant zero-ops RAG pipelineNeed custom embeddings/control
IndexingAutomatic (6hr cycle)Manual via API
GenerationBuilt-in optionalBring your own LLM
Data sourcesR2 or websiteManual insert
Best forDocs, support, enterprise searchCustom ML pipelines, real-time

AI Search vs Direct Workers AI

FactorAI SearchWorkers AI (direct)
ContextAutomatic retrievalManual context building
Use whenNeed RAG (search + generate)Simple generation tasks
IndexingBuilt-inNot applicable
Best forKnowledge bases, docsSimple chat, transformations

search() vs aiSearch()

MethodReturnsUse When
search()Search results onlyBuilding custom UI, need raw chunks
aiSearch()AI response + resultsNeed ready-to-use answer (chatbot, Q&A)

Real-time Updates Consideration

AI Search is NOT ideal if:

  • Need real-time content updates (<6 hours)
  • Content changes multiple times per hour
  • Strict freshness requirements

AI Search IS ideal if:

  • Content relatively stable (docs, policies, knowledge bases)
  • 6-hour refresh acceptable
  • Prefer zero-ops over real-time

Platform Limits

LimitValue
Max instances per account10
Max files per instance100,000
Max file size4 MB
Index frequencyEvery 6 hours
Force Sync rate limitOnce per 30 seconds
Filter nesting depth2 levels
Filters per compound10
Score threshold range0.0 - 1.0

Reading Order

Navigate these references based on your task:

TaskReadEst. Time
Understand AI SearchREADME only5 min
Implement basic searchREADME → api.md10 min
Configure data sourceREADME → configuration.md10 min
Production patternspatterns.md15 min
Debug issuesgotchas.md10 min
Full implementationREADME → api.md → patterns.md30 min

In This Reference

  • api.md - API endpoints, methods, TypeScript interfaces
  • configuration.md - Setup, data sources, wrangler config
  • patterns.md - Common patterns, decision guidance, code examples
  • gotchas.md - Troubleshooting, code-level gotchas, limits

See Also