Quick Start
Embedding Functions
Sync Functions
Async Functions
Configuration
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
model | string | 'text-embedding-3-small' | Embedding model |
dimensions | number | 1536 | Vector dimensions |
apiKey | string | undefined | API key (uses env var if not set) |
baseUrl | string | undefined | Custom API base URL |
Supported Models
| Model | Dimensions | Provider |
|---|---|---|
text-embedding-3-small | 1536 | OpenAI |
text-embedding-3-large | 3072 | OpenAI |
text-embedding-ada-002 | 1536 | OpenAI |
embed-english-v3.0 | 1024 | Cohere |
embed-multilingual-v3.0 | 1024 | Cohere |
Similarity Functions
Result Types
EmbeddingResult
BatchEmbeddingResult
Common Patterns
- Semantic Search
- Document Clustering
- RAG Context
Best Practices
Use batch embeddings for multiple texts
Use batch embeddings for multiple texts
Call
embeddings() once with an array instead of calling embed() multiple times.Cache embeddings for static content
Cache embeddings for static content
Store embeddings in a database to avoid regenerating them for unchanged content.
Choose the right model
Choose the right model
Use
text-embedding-3-small for speed, text-embedding-3-large for accuracy.
