Skip to main content
Embedders convert text into high-dimensional vectors. Similar texts produce similar vectors, which enables semantic search in a vector database.

OpenAIEmbedder

Uses OpenAI’s embedding models. The most common choice.
str
default:"text-embedding-3-small"
OpenAI embedding model. Options include text-embedding-3-small, text-embedding-3-large, and text-embedding-ada-002.
int
Output vector dimensions. Defaults to the model’s native dimensions. text-embedding-3-small supports up to 1536.
str
OpenAI API key. Defaults to the OPENAI_API_KEY environment variable.

Model Comparison

VoyageAIEmbedder

Uses Voyage AI’s embedding models, which excel at domain-specific and multilingual content.
str
default:"voyage-2"
Voyage AI model. Options include voyage-2, voyage-large-2, and others.
int
default:"1024"
Output vector dimensions.
str
Voyage AI API key. Defaults to the VOYAGE_API_KEY environment variable.
Requires the voyageai package. Install with pip install voyageai.

Using Embedders

With Knowledge

Pass an embedder when creating a knowledge base:

Standalone

Generate embeddings directly:

Batch Embedding

Embed multiple texts efficiently in a single API call:

FallbackEmbedder

Automatically fail over across multiple embedding providers. If the primary provider fails (rate limit, auth error, timeout), the next one is tried.
The fallback embedder inherits dimensions from the primary provider and automatically switches providers on failure. Call embedder.reset() to return to the primary provider.
Errors are classified by type (auth, rate limit, timeout, network) using duck typing on exception class names and messages — no provider SDK imports needed.

Creating a Custom Embedder

Subclass Embedder and implement the embedding methods:

Embedder Interface

Make sure the dimensions on your embedder matches the dimensions on your vector database. Mismatched dimensions will cause errors during search.