> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Supabase

> Generate embeddings with Prisma AIRS AI Gateway and store them in Supabase pgvector

Supabase provides Postgres with pgvector for AI applications. With the AI Gateway, generate embeddings using 3,000+ models and store them in Supabase for efficient retrieval.

## Prerequisites

* Supabase project API key
* [AI Gateway API key](https://stratacloudmanager.paloaltonetworks.com/)

## Setup

### 1. Install Dependencies

```sh theme={"system"}
pip install supabase
```

### 2. Prepare Database

**1. Create Supabase Project**

Go to [Supabase](https://supabase.com/dashboard/sign-in) and create a new project.

**2. Enable pgvector**

In **Database → Extensions**, enable `pgvector`. Or run:

```sql theme={"system"}
create extension vector;
```

**3. Create Documents Table**

Create a table for documents and embeddings. OpenAI's `text-embedding-ada-002` outputs 1536 dimensions:

```sql theme={"system"}
create table documents (
  id bigserial primary key,
  content text,
  embedding vector(1536)
);
```

### 3. Configure Clients

## Generate & Store Embeddings

```python theme={"system"}
# Generate embedding
response = client.embeddings.create(
    model="text-embedding-ada-002",
    input="The food was delicious and the waiter..."
)

embedding = response.data[0].embedding

# Store in Supabase
result = supabase.table('documents').insert({
    "content": "The food was delicious and the waiter...",
    "embedding": embedding
}).execute()
```

## Switch Providers

Change the provider to use different embedding models:

> [!NOTE]
>
> Cohere's `embed-english-v3.0` outputs 1024 dimensions. Create a separate table with `vector(1024)` for Cohere embeddings.

## Next Steps

> **[Model Catalog](https://docs.portkey.ai/docs/aigw/product/model-catalog.md)**
>
> Set up embedding providers

> **[Supported Providers](https://docs.portkey.ai/docs/aigw/integrations/llms.md)**
>
> See all 3,000+ supported models


## Related topics

- [Overview](https://docs.portkey.ai/docs/aigw/integrations/libraries.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.