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/configuration.md
1# AI Search Configuration23## Worker Setup45```jsonc6// wrangler.jsonc7{8"ai": { "binding": "AI" }9}10```1112```typescript13interface Env {14AI: Ai;15}1617const answer = await env.AI.autorag("my-instance").aiSearch({18query: "How do I configure caching?",19model: "@cf/meta/llama-3.3-70b-instruct-fp8-fast"20});21```2223## Data Sources2425### R2 Bucket2627Dashboard: AI Search → Create Instance → Select R2 bucket2829**Supported formats:** `.md`, `.txt`, `.html`, `.pdf`, `.doc`, `.docx`, `.csv`, `.json`3031**Auto-indexed metadata:** `filename`, `folder`, `timestamp`3233### Website Crawler3435Requirements:36- Domain on Cloudflare37- `sitemap.xml` at root38- Bot protection must allow `CloudflareAISearch` user agent3940## Path Filtering (R2)4142```43docs/**/*.md # All .md in docs/ recursively44**/*.draft.md # Exclude (use in exclude patterns)45```4647## Indexing4849- **Automatic:** Every 6 hours50- **Force Sync:** Dashboard button (30s rate limit between syncs)51- **Pause:** Settings → Pause Indexing (existing index remains searchable)5253## Service API Token5455Dashboard: AI Search → Instance → Use AI Search → API → Create Token5657Permissions:58- **Read** - search operations59- **Edit** - instance management6061Store securely:62```bash63wrangler secret put AI_SEARCH_TOKEN64```6566## Multi-Environment6768```toml69# wrangler.toml70[env.production.vars]71AI_SEARCH_INSTANCE = "prod-docs"7273[env.staging.vars]74AI_SEARCH_INSTANCE = "staging-docs"75```7677```typescript78const answer = await env.AI.autorag(env.AI_SEARCH_INSTANCE).aiSearch({ query });79```8081## Monitoring8283```typescript84const instances = await env.AI.autorag("_").listInstances();85console.log(instances.find(i => i.name === "docs"));86```8788Dashboard shows: files indexed, status, last index time, storage usage.89