Supabase Vecs: a vector client for Postgres
Vecs is a Python client that makes Postgres with the pgvector extension behave like a dedicated vector store, handling collection (table) creation, indexing, upserts, and similarity queries by cosine, L2, or max inner product with a jsonb-backed metadata filter DSL. Each collection maps to a plain table in a `vecs` schema (text id, vector column, jsonb metadata), so users can drop down to SQL when needed. On Supabase, collections can be exposed as public views and queried from supabase-js. Possible future work includes built-in text/image embedding transforms and an async client.
Related posts
- Hugging Face is now supported in Supabase
Supabase mediumAdeptSupabase adds first-class Hugging Face support for generating embeddings stored in pgvector, as an open-source, self-hostable alternative to OpenAI's text-embedding-ada-002. The Python vecs client gains "adapters" that chunk text and embed it automatically on upsert and query. Edge Functions can run Transformers.js inference in Deno, and small models can even run in the browser and query pgvector through PostgREST and RLS. Supabase recommends lower-dimension models such as gte-small for cheaper storage and faster retrieval, and notes current limits: 2-6s cold starts from model downloads, and no turnkey audio/image decoding in Deno.
- Introducing Vector Buckets
Supabase mediumAdeptSupabase Vector Buckets are a new Storage bucket type that keeps embeddings in S3-backed object storage with built-in k-NN similarity search, supporting up to 50M vectors per index, cosine distance and metadata filtering. Indexes are queried through the Supabase SDKs or from Postgres via a foreign data wrapper, so results can be joined with relational tables. They target sub-second (hundreds of milliseconds) rather than single-digit-millisecond latency, so the recommended pattern is to keep hot, latency-sensitive or transactional vectors in pgvector and move large warm or cold archives to Vector Buckets. The feature is in free Public Alpha for Pro projects in five AWS regions.
- ChatGPT plugins now support Postgres & Supabase
Supabase mediumAdeptSupabase contributed Postgres and Supabase datastore providers to OpenAI's ChatGPT Retrieval Plugin, storing text-embedding-ada-002 embeddings in pgvector. The Postgres provider connects directly via psycopg2, while the Supabase provider goes through PostgREST to enable Row Level Security. Both share the same documents schema and use a plpgsql match function that filters by source, author and date and ranks results by inner product distance. A walkthrough ingests the PostgreSQL 15 docs (about 7,904 chunks), adds an approximate ivfflat index with lists ≈ rows/1000, and registers the local plugin with ChatGPT to answer documentation questions.
- Storing OpenAI embeddings in Postgres with pgvector
Supabase mediumAdeptpgvector adds a vector data type and distance operators (Euclidean <->, negative inner product <#>, cosine <=>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database. The walkthrough creates a documents table, a match_documents SQL function that filters by a cosine-similarity threshold, and an IVFFlat index sized at roughly 4 * sqrt(rows) lists. It then generates embeddings in JavaScript and builds Deno Edge Functions for semantic search and for retrieval-augmented answers with text-davinci-003, keeping injected context under about 1500 tokens to fit the 4000-token limit.
- How to Use pgvector for Similarity Search on Heroku Postgres
Heroku Engineering mediumAdeptHeroku Postgres now supports the pgvector extension on Standard-tier and higher databases running Postgres 15, enabled with `CREATE EXTENSION vector;`. A worked example loads 100-dimensional Wikipedia2Vec word embeddings for a list of animals into a VECTOR(100) column using Python, psycopg and pgvector-python. It then runs nearest-neighbour queries with the Euclidean (`<->`), cosine (`<=>`) and inner product (`<#>`) operators. On indexing, IVFFlat and HNSW indexes switch queries to approximate search, should match the distance function you query with most, and IVFFlat should be built after data is loaded for better recall.