Configuring Cloudflare
Conductor runs on Cloudflare’s edge platform. Here’s how to set up everything you need. This guide covers: Workers AI, KV, D1, R2, Vectorize, Durable Objects, and Queues.Workers AI
AI models running at the edge. No API keys, no external dependencies.Setup
Add towrangler.toml:
Available Models
Text Generation:@cf/meta/llama-3.1-8b-instruct- Fast, good quality (recommended)@cf/meta/llama-3-8b-instruct- Previous generation@cf/mistral/mistral-7b-instruct-v0.1- Fast, creative
@cf/baai/bge-base-en-v1.5- 768 dimensions (recommended)@cf/baai/bge-small-en-v1.5- 384 dimensions (faster)@cf/baai/bge-large-en-v1.5- 1024 dimensions (best quality)
@cf/stabilityai/stable-diffusion-xl-base-1.0
Usage in Ensembles
Limits
- Free: 10,000 neurons/day (~100 requests for Llama 3.1)
- Paid: Unlimited, pay per neuron
KV (Key-Value Storage)
Fast, globally replicated key-value store. Perfect for caching.Create Namespace
Configure
Add towrangler.toml:
Usage in Ensembles
KV Operations
Get:Limits
- Free: 100,000 reads/day, 1,000 writes/day
- Paid: Unlimited, 5/million writes
- Key size: Max 512 bytes
- Value size: Max 25MB
- Latency: <10ms globally
D1 (SQL Database)
SQLite at the edge. Perfect for structured data.Create Database
Configure
Add towrangler.toml:
Create Schema
migrations/0001_initial_schema.sql:
Usage in Ensembles
Query (SELECT):D1 CLI Commands
Limits
- Free: 5M rows read/day, 100k rows written/day
- Paid: Unlimited, 1/1M rows written
- Database size: 10GB (can request increase)
- Query time: 30 seconds max
R2 (Object Storage)
S3-compatible object storage. No egress fees.Create Bucket
Configure
Add towrangler.toml:
Usage in Ensembles
Upload:R2 CLI Commands
Limits
- Storage: 10GB free, then $0.015/GB/month
- Class A operations (writes): 1M free/month, then $4.50/million
- Class B operations (reads): 10M free/month, then $0.36/million
- Egress: FREE (no egress fees!)
- Max object size: 5TB
Vectorize (Vector Database)
Vector similarity search. Perfect for RAG and semantic search.Create Index
- 384:
@cf/baai/bge-small-en-v1.5 - 768:
@cf/baai/bge-base-en-v1.5(recommended) - 1024:
@cf/baai/bge-large-en-v1.5 - 1536: OpenAI
text-embedding-3-small
- cosine: Best for normalized vectors (recommended)
- euclidean: L2 distance
- dot-product: Inner product
Configure
Add towrangler.toml:
Usage in Ensembles
Insert Vectors:Vectorize CLI Commands
Limits
- Free: Included in Workers plan
- Max vectors: 5M (can request increase)
- Max dimensions: 1536
- Query latency: ~50ms
Durable Objects
Stateful edge workers. Perfect for real-time features.Configure
Add towrangler.toml:
Export Classes
Insrc/index.ts:
Usage
Conductor uses Durable Objects internally for:- HITL (Human-in-the-Loop): Approval workflows
- Long-running executions: State persistence
Queues
Asynchronous task processing.Create Queue
Configure
Add towrangler.toml:
Usage in Ensembles
Send Message:src/index.ts):
Complete Configuration Example
Here’s a fullwrangler.toml with all services:
Best Practices
- Use KV for caching - Fast and cheap
- Use D1 for structured data - When you need SQL
- Use R2 for large files - No egress fees
- Use Vectorize for semantic search - Native vector support
- Use Queues for async work - Don’t block requests
- Separate environments - dev, staging, production
- Monitor limits - Check Cloudflare dashboard regularly
- Optimize queries - Add indexes to D1 tables
Cost Optimization
Stay in Free Tier
- Workers: 100k requests/day
- KV: 100k reads, 1k writes/day
- D1: 5M reads, 100k writes/day
- R2: 10GB storage, 1M writes, 10M reads/month
- Workers AI: 10k neurons/day
Tips to Reduce Costs
- Cache aggressively - Use KV to cache AI/API results
- Use Cloudflare AI - Cheaper than external providers
- Batch D1 operations - Reduce write counts
- Use R2 for storage - No egress fees
- Monitor usage - Set up billing alerts

