AI & Vectors

AI Integrations

Learn how to integrate Supabase with LlamaIndex, a data framework for your LLM applications.

Learn how to integrate Supabase with LlamaIndex, a data framework for your LLM applications.

This guide will walk you through a basic example using the LlamaIndex SupabaseVectorStore.

Project setup

Let's create a new Postgres database. This is as simple as starting a new Project in Supabase:

  1. Create a new project in the Supabase dashboard.
  2. Enter your project details. Remember to store your password somewhere safe.

Your database will be available in less than a minute.

Finding your credentials:

You can find your project credentials inside the project settings, including:

Launching a notebook

Launch our LlamaIndex notebook in Colab:

At the top of the notebook, you'll see a button Copy to Drive. Click this button to copy the notebook to your Google Drive.

Fill in your OpenAI credentials

Inside the Notebook, add your OPENAI_API_KEY key. Find the cell which contains this code:


_10
import os
_10
os.environ['OPENAI_API_KEY'] = "[your_openai_api_key]"

Connecting to your database

Inside the Notebook, find the cell which specifies the DB_CONNECTION. It will contain some code like this:


_10
DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"
_10
_10
# create vector store client
_10
vx = vecs.create_client(DB_CONNECTION)

Replace the DB_CONNECTION with your own connection string for your database. You can find the Postgres connection string in the Database Settings of your Supabase project.

Stepping through the notebook

Now all that's left is to step through the notebook. You can do this by clicking the "execute" button (ctrl+enter) at the top left of each code cell. The notebook guides you through the process of creating a collection, adding data to it, and querying it.

You can view the inserted items in the Table Editor, by selecting the vecs schema from the schema dropdown.

Colab documents

Resources

  • Visit the LlamaIndex + SupabaseVectorStore docs
  • Visit the official LlamaIndex repo