Skip to main content
Generate text embeddings with AI SDK and native fallback providers.

Quick Start

1

Simple Usage

Direct Embedding API

For more control, use the embedding functions directly:

Embedding Models

OpenAI Models

Google Models

Cohere Models

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:
  1. AI SDK (preferred): When ai package is installed
  2. Native: Falls back to direct OpenAI client

Force Backend

Environment Variable

Similarity Functions

Built-in similarity functions for comparing embeddings:

Performance Tips

  1. Batch embeddings: Use embedMany for multiple texts
  2. Cache embeddings: Store embeddings to avoid re-computation
  3. Choose model wisely: text-embedding-3-small is fast and cheap

Error Handling

TypeScript Types

Embeddings CLI

Embeddings CLI overview

Knowledge Base

Knowledge Base overview