Vectorize
Power your AI agents with lightning-fast vector search. Cloudflare Vectorize is a globally distributed vector database that enables your AI agents to perform semantic search, similarity matching, and retrieval-augmented generation (RAG) at massive scale with sub-millisecond latency.
Key Features
- Global Distribution: Vector indexes replicated across Cloudflare's edge network
- High Performance: High performant vector similarity search
- Massive Scale: Billions of vectors with automatic sharding
- Multiple Metrics: Cosine similarity, Euclidean distance, and dot product
- Real-time Updates: Insert, update, and delete vectors instantly
- Embedding Support: Compatible with OpenAI, Cohere, Google, and custom embeddings
Getting Started
Wrangler Configuration
First, add vectorize indexes in your wrangler.json:
Hello World Vector Search
Create a simple agent that performs semantic search:
MCP Integration
Expose vector search capabilities through MCP tools:
TypeScript API Reference
Vector Operations
VECTORIZE.query(vector: number[], options?: QueryOptions): Promise<QueryResult>
Search for similar vectors using cosine similarity, Euclidean distance, or dot product.
VECTORIZE.upsert(vectors: Vector[]): Promise<UpsertResult>
Insert or update vectors in the index with automatic batching.
VECTORIZE.deleteById(ids: string[]): Promise<DeleteResult>
Remove vectors from the index by their IDs.
VECTORIZE.getByIds(ids: string[]): Promise<Vector[]>
Retrieve specific vectors by their IDs with metadata.
Index Management
VECTORIZE.describe(): Promise<IndexInfo>
Get information about the index including dimensions and vector count.
VECTORIZE.getStats(): Promise<IndexStats>
Retrieve index statistics and performance metrics.
Examples
Knowledge Base Agent
Document Similarity Agent
Best Practices
Vector Dimensions
Batch Operations
Limitations
- Vector Dimensions: Maximum 1536 dimensions per vector
- Index Size: Maximum 5 million vectors per index
- Metadata Size: Maximum 1KB metadata per vector
- Query Rate: 1,000 queries per second per index
- Batch Size: Maximum 1,000 vectors per upsert operation
Supported Embeddings
Vectorize works with embeddings from popular AI providers and custom models:
OpenAI Embeddings
- text-embedding-ada-002: 1536 dimensions (recommended)
- text-embedding-3-small: 1536 dimensions
- text-embedding-3-large: 3072 dimensions (requires custom configuration)
Cohere Embeddings
- embed-english-v3.0: 1024 dimensions
- embed-multilingual-v3.0: 1024 dimensions
- embed-english-light-v3.0: 384 dimensions
Google Embeddings
- text-embedding-gecko: 768 dimensions
- textembedding-gecko-multilingual: 768 dimensions
Custom Embeddings
- Sentence Transformers: 384-1536 dimensions
- Hugging Face Models: Variable dimensions (up to 1536)
- Custom Models: Any model outputting vectors ≤ 1536 dimensions
Related Services
- Memory Store (KV) - Cache frequently accessed vectors
- Storage (R2) - Store original documents and large embeddings
- Analytics Storage - Track search performance metrics