Agent Embeddings
PraisonAI provides embedding capabilities powered by AI SDK when available, with automatic fallback to native providers. Embeddings are useful for semantic search, memory systems, and knowledge retrieval.Quick Start
Direct Embedding API
For more control, use the embedding functions directly:Embedding Models
OpenAI Models
| Model | Dimensions | Description |
|---|---|---|
text-embedding-3-small | 1536 | Fast, cost-effective (default) |
text-embedding-3-large | 3072 | Higher quality |
text-embedding-ada-002 | 1536 | Legacy model |
Google Models
| Model | Dimensions | Description |
|---|---|---|
text-embedding-004 | 768 | Google embedding |
Cohere Models
| Model | Dimensions | Description |
|---|---|---|
embed-english-v3.0 | 1024 | English optimized |
embed-multilingual-v3.0 | 1024 | Multilingual support |
Integration with Knowledge Base
Use embeddings with the KnowledgeBase for semantic search:Integration with Memory
Use embeddings for semantic memory search:Backend Selection
PraisonAI automatically selects the best backend:- AI SDK (preferred): When
aipackage is installed - Native: Falls back to direct OpenAI client
Force Backend
Environment Variable
Similarity Functions
Built-in similarity functions for comparing embeddings:Performance Tips
- Batch embeddings: Use
embedManyfor multiple texts - Cache embeddings: Store embeddings to avoid re-computation
- Choose model wisely:
text-embedding-3-smallis fast and cheap

