pgvector extension. Refer to the Supabase blog post for more information.
This guide provides a quick overview for getting started with Supabase vector stores. For detailed documentation of all SupabaseVectorStore features and configurations head to the API reference.
Overview
Integration details
| Class | Package | PY support | Version |
|---|---|---|---|
SupabaseVectorStore | @langchain/community | ✅ |
Setup
To use Supabase vector stores, you’ll need to set up a Supabase database and install the@langchain/community integration package. You’ll also need to install the official @supabase/supabase-js SDK as a peer dependency.
This guide will also use OpenAI embeddings, which require you to install the @langchain/openai integration package. You can also use other supported embeddings models if you wish.
pgvector and create the necessary table and functions:
Credentials
Once you’ve done this set theSUPABASE_PRIVATE_KEY and SUPABASE_URL environment variables:
Instantiation
Manage vector store
Add items to vector store
Delete items from vector store
Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:Metadata Query Builder Filtering
You can also use query builder-style filtering similar to how the Supabase JavaScript library works instead of passing an object. Note that since most of the filter properties are in the metadata column, you need to use arrow operators (-> for integer or ->> for text) as defined in Postgrest API documentation and specify the data type of the property (e.g. the column should look something likemetadata->some_int_prop_name::int).
Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:API reference
For detailed documentation of allSupabaseVectorStore features and configurations head to the API reference.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.