Skip to main content
Vector embeddings are numerical representations that capture the semantic meaning of data. Learn how to generate, store, and work with embeddings in Supabase.

What are Embeddings?

Embeddings convert text, images, or other data into arrays of numbers (vectors) that capture semantic relationships:
The closer two vectors are in the embedding space, the more semantically similar their source content.

Generating Embeddings

OpenAI Embeddings

OpenAI provides state-of-the-art embedding models:

Available Models

Storing Embeddings

Database Schema

Create a table with a vector column:

Insert Embeddings

Batch Insert

For better performance with many documents:

Chunking Strategy

Long documents should be split into chunks before embedding:

Updating Embeddings

When content changes, regenerate embeddings:

Best Practices

Embedding Dimensions: Use the same model and dimension throughout your application. Mixing models will break similarity search.
Storage Costs: Each 1536-dimensional vector takes ~6KB of storage. Plan accordingly for large datasets.
Caching: Cache embeddings to avoid regenerating them. Store the model version in metadata to track when to regenerate.

Metadata for Filtering

Store metadata to filter results before similarity search:

Next Steps

Similarity Search

Learn how to search using embeddings

pgvector Extension

Deep dive into pgvector features

AI Examples

Complete RAG and search examples

Edge Functions

Generate embeddings in Edge Functions