Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/ai-search/README.md
1# Cloudflare AI Search Reference23Expert guidance for implementing Cloudflare AI Search (formerly AutoRAG), Cloudflare's managed semantic search and RAG service.45## Overview67**AI Search** is a managed RAG (Retrieval-Augmented Generation) pipeline that combines:8- Automatic semantic indexing of your content9- Vector similarity search10- Built-in LLM generation1112**Key value propositions:**13- **Zero vector management** - No manual embedding, indexing, or storage14- **Auto-indexing** - Content automatically re-indexed every 6 hours15- **Built-in generation** - Optional AI response generation from retrieved context16- **Multi-source** - Index from R2 buckets or website crawls1718**Data source options:**19- **R2 bucket** - Index files from Cloudflare R2 (supports MD, TXT, HTML, PDF, DOC, CSV, JSON)20- **Website** - Crawl and index website content (requires Cloudflare-hosted domain)2122**Indexing lifecycle:**23- Automatic 6-hour refresh cycle24- Manual "Force Sync" available (30s rate limit)25- Not designed for real-time updates2627## Quick Start2829**1. Create AI Search instance in dashboard:**30- Go to Cloudflare Dashboard → AI Search → Create31- Choose data source (R2 or website)32- Configure instance name and settings3334**2. Configure Worker:**3536```jsonc37// wrangler.jsonc38{39"ai": {40"binding": "AI"41}42}43```4445**3. Use in Worker:**4647```typescript48export default {49async fetch(request, env) {50const answer = await env.AI.autorag("my-search-instance").aiSearch({51query: "How do I configure caching?",52model: "@cf/meta/llama-3.3-70b-instruct-fp8-fast"53});5455return Response.json({ answer: answer.response });56}57};58```5960## When to Use AI Search6162### AI Search vs Vectorize6364| Factor | AI Search | Vectorize |65|--------|-----------|-----------|66| **Management** | Fully managed | Manual embedding + indexing |67| **Use when** | Want zero-ops RAG pipeline | Need custom embeddings/control |68| **Indexing** | Automatic (6hr cycle) | Manual via API |69| **Generation** | Built-in optional | Bring your own LLM |70| **Data sources** | R2 or website | Manual insert |71| **Best for** | Docs, support, enterprise search | Custom ML pipelines, real-time |7273### AI Search vs Direct Workers AI7475| Factor | AI Search | Workers AI (direct) |76|--------|-----------|---------------------|77| **Context** | Automatic retrieval | Manual context building |78| **Use when** | Need RAG (search + generate) | Simple generation tasks |79| **Indexing** | Built-in | Not applicable |80| **Best for** | Knowledge bases, docs | Simple chat, transformations |8182### search() vs aiSearch()8384| Method | Returns | Use When |85|--------|---------|----------|86| `search()` | Search results only | Building custom UI, need raw chunks |87| `aiSearch()` | AI response + results | Need ready-to-use answer (chatbot, Q&A) |8889### Real-time Updates Consideration9091**AI Search is NOT ideal if:**92- Need real-time content updates (<6 hours)93- Content changes multiple times per hour94- Strict freshness requirements9596**AI Search IS ideal if:**97- Content relatively stable (docs, policies, knowledge bases)98- 6-hour refresh acceptable99- Prefer zero-ops over real-time100101## Platform Limits102103| Limit | Value |104|-------|-------|105| Max instances per account | 10 |106| Max files per instance | 100,000 |107| Max file size | 4 MB |108| Index frequency | Every 6 hours |109| Force Sync rate limit | Once per 30 seconds |110| Filter nesting depth | 2 levels |111| Filters per compound | 10 |112| Score threshold range | 0.0 - 1.0 |113114## Reading Order115116Navigate these references based on your task:117118| Task | Read | Est. Time |119|------|------|-----------|120| **Understand AI Search** | README only | 5 min |121| **Implement basic search** | README → api.md | 10 min |122| **Configure data source** | README → configuration.md | 10 min |123| **Production patterns** | patterns.md | 15 min |124| **Debug issues** | gotchas.md | 10 min |125| **Full implementation** | README → api.md → patterns.md | 30 min |126127## In This Reference128129- **[api.md](api.md)** - API endpoints, methods, TypeScript interfaces130- **[configuration.md](configuration.md)** - Setup, data sources, wrangler config131- **[patterns.md](patterns.md)** - Common patterns, decision guidance, code examples132- **[gotchas.md](gotchas.md)** - Troubleshooting, code-level gotchas, limits133134## See Also135136- [Cloudflare AI Search Docs](https://developers.cloudflare.com/ai-search/)137- [Workers AI Docs](https://developers.cloudflare.com/workers-ai/)138- [Vectorize Docs](https://developers.cloudflare.com/vectorize/)139