Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: Update from supabase-py PRs #1240, #1283, #1318 (#41087)

Guilherme Souzaa40bf4dfa436
diff --git a/apps/docs/content/guides/auth/oauth-server/getting-started.mdx b/apps/docs/content/guides/auth/oauth-server/getting-started.mdx
index e9033142c1f..e7fc561c59e 100644
--- a/apps/docs/content/guides/auth/oauth-server/getting-started.mdx
+++ b/apps/docs/content/guides/auth/oauth-server/getting-started.mdx
@@ -494,7 +494,71 @@ Store the client secret securely. It will only be shown once. If you lose it, yo
</TabPanel>
<TabPanel id="programmatically" label="Programmatically">
-You can register clients programmatically by calling your project's auth server admin endpoint with a secret key:
+You can register clients programmatically using the SDK admin endpoints or by calling your project's auth server admin endpoint directly.
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
+```typescript
+import { createClient } from '@supabase/supabase-js'
+
+const supabase = createClient(
+ 'https://your-project.supabase.co',
+ 'your-service-role-key' // Use service_role key for admin operations
+)
+
+// Create an OAuth client
+const { data, error } = await supabase.auth.admin.oauth.createClient({
+ name: 'My Third-Party App',
+ redirect_uris: ['https://my-app.com/auth/callback', 'https://my-app.com/auth/silent-callback'],
+ client_type: 'confidential',
+})
+
+if (error) {
+ console.error('Error creating client:', error)
+} else {
+ console.log('Client created:', data)
+ console.log('Client ID:', data.client_id)
+ console.log('Client Secret:', data.client_secret) // Store this securely!
+}
+```
+
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+
+supabase = create_client(
+ 'https://your-project.supabase.co',
+ 'your-service-role-key' # Use service_role key for admin operations
+)
+
+# Create an OAuth client
+response = supabase.auth.admin.oauth.create_client({
+ 'name': 'My Third-Party App',
+ 'redirect_uris': [
+ 'https://my-app.com/auth/callback',
+ 'https://my-app.com/auth/silent-callback'
+ ],
+ 'client_type': 'confidential'
+})
+
+print('Client created:', response)
+print('Client ID:', response.client_id)
+print('Client Secret:', response.client_secret) # Store this securely!
+```
+
+</TabPanel>
+</$Show>
+<TabPanel id="curl" label="cURL">
**Production:**
@@ -538,6 +602,9 @@ Response:
}
```
+</TabPanel>
+</Tabs>
+
<Admonition type="note">
For complete API documentation, see the [OAuth Admin API reference](/docs/reference/javascript/auth-admin-oauth-admin).
@@ -548,6 +615,39 @@ For complete API documentation, see the [OAuth Admin API reference](/docs/refere
To view all registered OAuth clients:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
+```typescript
+const { data, error } = await supabase.auth.admin.oauth.listClients()
+
+if (error) {
+ console.error('Error listing clients:', error)
+} else {
+ console.log('OAuth clients:', data)
+}
+```
+
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+clients = supabase.auth.admin.oauth.list_clients()
+
+print('OAuth clients:', clients)
+```
+
+</TabPanel>
+</$Show>
+<TabPanel id="curl" label="cURL">
+
**Production:**
```bash
@@ -565,6 +665,9 @@ curl 'http://localhost:54321/auth/v1/admin/oauth/clients' \
</TabPanel>
</Tabs>
+</TabPanel>
+</Tabs>
+
## Customizing tokens (optional)
By default, OAuth access tokens include standard claims like `user_id`, `role`, and `client_id`. If you need to customize tokens—for example, to set a specific `audience` claim for third-party validation or add client-specific metadata—use [Custom Access Token Hooks](/docs/guides/auth/auth-hooks/access-token-hook).
diff --git a/apps/docs/content/guides/storage/analytics/creating-analytics-buckets.mdx b/apps/docs/content/guides/storage/analytics/creating-analytics-buckets.mdx
index a20677460e3..8d57ae19ccf 100644
--- a/apps/docs/content/guides/storage/analytics/creating-analytics-buckets.mdx
+++ b/apps/docs/content/guides/storage/analytics/creating-analytics-buckets.mdx
@@ -17,7 +17,16 @@ You can create an analytics bucket using either the Supabase SDK or the Supabase
### Using the Supabase SDK
-```ts
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
+```typescript
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('https://your-project.supabase.co', 'your-service-key')
@@ -31,6 +40,24 @@ if (error) {
}
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+
+supabase = create_client('https://your-project.supabase.co', 'your-service-key')
+
+response = supabase.storage.analytics().create('analytics-data')
+
+print('Analytics bucket created:', response)
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Using the Supabase Dashboard
1. Navigate to the **Storage** section in the Supabase Dashboard.
diff --git a/apps/docs/content/guides/storage/uploads/resumable-uploads.mdx b/apps/docs/content/guides/storage/uploads/resumable-uploads.mdx
index 4a9619a3847..6526563c6ab 100644
--- a/apps/docs/content/guides/storage/uploads/resumable-uploads.mdx
+++ b/apps/docs/content/guides/storage/uploads/resumable-uploads.mdx
@@ -306,6 +306,44 @@ Uppy has integrations with different frameworks:
Resumable uploads also supports using signed upload tokens to created time-limited URLs that you can share to your users by invoking the `createSignedUploadUrl` method on the SDK and including the returned token in the `x-signature` header of the resumable upload.
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
+```typescript
+// Create a signed upload URL
+const { data } = await supabase.storage.from('bucket_name').createSignedUploadUrl('file_path', {
+ upsert: true, // Optional: allow overwriting existing files
+})
+
+// Use the signed URL token in resumable upload headers
+// Include data.token in the x-signature header
+```
+
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+# Create a signed upload URL with upsert option
+response = supabase.storage.from_('bucket_name').create_signed_upload_url(
+ 'file_path',
+ options={'upsert': 'true'} # Optional: allow overwriting existing files
+)
+
+# Use the signed URL token in resumable upload headers
+# Include response.token in the x-signature header
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
See this [full example using Uppy with signed URLs](https://github.com/supabase/supabase/tree/master/examples/storage/resumable-upload-signed-uppy) for more context.
## Overwriting files
diff --git a/apps/docs/content/guides/storage/vector/creating-vector-buckets.mdx b/apps/docs/content/guides/storage/vector/creating-vector-buckets.mdx
index 389cb222380..d69faa30ae0 100644
--- a/apps/docs/content/guides/storage/vector/creating-vector-buckets.mdx
+++ b/apps/docs/content/guides/storage/vector/creating-vector-buckets.mdx
@@ -13,7 +13,7 @@ Vector buckets organize your vector data into logical units. Within each bucket,
## Creating a Vector bucket
-You can create vector buckets using either the Supabase Dashboard or the JavaScript SDK.
+You can create vector buckets using either the Supabase Dashboard or the SDK.
### Using the Supabase Dashboard
@@ -25,7 +25,16 @@ You can create vector buckets using either the Supabase Dashboard or the JavaScr
Your vector bucket is now ready. The next step is to create indexes within it.
-### Using the JavaScript SDK
+### Using the SDK
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
```typescript
import { createClient } from '@supabase/supabase-js'
@@ -38,6 +47,25 @@ await supabase.storage.vectors.createBucket('embeddings')
console.log('✓ Vector bucket created: embeddings')
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+
+supabase = create_client('https://your-project.supabase.co', 'your-service-key')
+
+# Create a vector bucket
+supabase.storage.vectors().create_bucket('embeddings')
+
+print('✓ Vector bucket created: embeddings')
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
## Creating indexes
Indexes organize vectors within a bucket with consistent dimensions and distance metrics. For comprehensive index management documentation, see [Working with Vector Indexes](/docs/guides/storage/vector/working-with-indexes).
@@ -51,7 +79,16 @@ Indexes organize vectors within a bucket with consistent dimensions and distance
5. Select the distance metric (`cosine`, `euclidean`, or `l2`).
6. Click **Create**.
-### Quick start: Creating an index via JavaScript SDK
+### Quick start: Creating an index via SDK
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
```typescript
const bucket = supabase.storage.vectors.from('embeddings')
@@ -67,6 +104,28 @@ await bucket.createIndex({
console.log('✓ Index created: documents-openai')
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+bucket = supabase.storage.vectors().from_('embeddings')
+
+# Create an index
+bucket.create_index(
+ index_name='documents-openai',
+ dimension=1536,
+ distance_metric='cosine',
+ data_type='float32'
+)
+
+print('✓ Index created: documents-openai')
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Key details
- **Dimension** must match your embedding model (e.g., 1536 for OpenAI)
diff --git a/apps/docs/content/guides/storage/vector/querying-vectors.mdx b/apps/docs/content/guides/storage/vector/querying-vectors.mdx
index 788e4b48d5f..7df0e3e6d2d 100644
--- a/apps/docs/content/guides/storage/vector/querying-vectors.mdx
+++ b/apps/docs/content/guides/storage/vector/querying-vectors.mdx
@@ -57,6 +57,34 @@ if (error) {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+
+supabase = create_client('https://your-project.supabase.co', 'your-service-key')
+
+index = supabase.storage.vectors().from_('embeddings').index('documents-openai')
+
+# Query with a vector embedding
+results = index.query(
+ query_vector={'float32': [0.1, 0.2, 0.3]}, # ... embedding of 1536 dimensions
+ topK=5,
+ return_distance=True,
+ return_metadata=True
+)
+
+if results:
+ # Results are ranked by similarity (lowest distance = most similar)
+ for rank, result in enumerate(results.vectors, 1):
+ print(f'{rank}. {result.metadata.get("title") if result.metadata else "N/A"}')
+ if result.distance is not None:
+ print(f' Similarity score: {result.distance:.4f}')
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -139,6 +167,55 @@ results.forEach((result) => {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+from openai import OpenAI
+import os
+
+supabase = create_client(...)
+openai = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))
+
+async def semantic_search(query, top_k=5):
+ # Embed the query
+ query_embedding = openai.embeddings.create(
+ model='text-embedding-3-small',
+ input=query
+ )
+
+ query_vector = query_embedding.data[0].embedding
+
+ # Search for similar vectors
+ results = supabase.storage.vectors() \
+ .from_('embeddings') \
+ .index('documents-openai') \
+ .query(
+ query_vector={'float32': query_vector},
+ topK=top_k,
+ return_distance=True,
+ return_metadata=True
+ )
+
+ return [
+ {
+ 'id': result.key,
+ 'title': result.metadata.get('title') if result.metadata else None,
+ 'similarity': 1 - result.distance if result.distance else 0, # Convert distance to similarity (0-1)
+ 'metadata': result.metadata
+ }
+ for result in results.vectors
+ ]
+
+# Usage
+results = semantic_search('How do I use vector search?')
+for result in results:
+ print(f'{result["title"]} ({result["similarity"] * 100:.1f}% similar)')
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -197,6 +274,31 @@ const { data } = await index.queryVectors({
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+index = supabase.storage.vectors() \
+ .from_('embeddings') \
+ .index('documents-openai')
+
+# Search with metadata filter
+results = index.query(
+ query_vector={'float32': [...embedding...]},
+ topK=10,
+ filter={
+ # Filter by metadata fields
+ 'category': 'electronics',
+ 'in_stock': True,
+ 'price': {'$lte': 500} # Less than or equal to 500
+ },
+ return_distance=True,
+ return_metadata=True
+)
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -248,6 +350,21 @@ if (!error) {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+index = supabase.storage.vectors().from_('embeddings').index('documents-openai')
+
+results = index.get('doc-1', 'doc-2', 'doc-3', return_data=True, return_metadata=True)
+
+if results:
+ for vector in results.vectors:
+ print(f'{vector.key}: {vector.metadata.get("title") if vector.metadata else "N/A"}')
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -303,6 +420,39 @@ do {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+index = supabase.storage.vectors().from_('embeddings').index('documents-openai')
+
+next_token = None
+page_count = 0
+
+while True:
+ results = index.list(
+ max_results=100,
+ next_token=next_token,
+ return_data=False, # Don't return embeddings for faster response
+ return_metadata=True
+ )
+
+ if not results:
+ break
+
+ page_count += 1
+ print(f'Page {page_count}: {len(results.vectors)} vectors')
+
+ for vector in results.vectors:
+ print(f' - {vector.key}: {vector.metadata.get("title") if vector.metadata else "N/A"}')
+
+ next_token = results.nextToken
+ if not next_token:
+ break
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -368,6 +518,39 @@ async function hybridSearch(queryVector, filters) {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+def hybrid_search(query_vector, filters):
+ index = supabase.storage.vectors().from_('embeddings').index('documents-openai')
+
+ # Get similar vectors with filters
+ vector_results = index.query(
+ query_vector={'float32': query_vector},
+ topK=100,
+ filter=filters,
+ return_distance=True,
+ return_metadata=True
+ )
+
+ # Get additional details from relational database
+ doc_ids = [v.metadata.get('doc_id') for v in vector_results.vectors if v.metadata and v.metadata.get('doc_id')]
+ details_response = supabase.table('documents').select('*').in_('id', doc_ids).execute()
+ details = details_response.data if details_response.data else []
+
+ # Merge results
+ return [
+ {
+ **vector.__dict__ if hasattr(vector, '__dict__') else {},
+ **next((d for d in details if d['id'] == vector.metadata.get('doc_id')), {})
+ }
+ for vector in vector_results.vectors
+ ]
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -398,6 +581,15 @@ LIMIT 50;
### RAG (retrieval-augmented generation)
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
import OpenAI from 'openai'
import { createClient } from '@supabase/supabase-js'
@@ -445,8 +637,72 @@ async function retrieveContextForLLM(userQuery) {
}
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from openai import OpenAI
+from supabase import create_client
+
+async def retrieve_context_for_llm(user_query):
+ supabase = create_client(...)
+ openai = OpenAI()
+
+ # 1. Embed the user query
+ query_embedding = openai.embeddings.create(
+ model='text-embedding-3-small',
+ input=user_query
+ )
+
+ # 2. Retrieve relevant documents
+ vector_results = supabase.storage.vectors() \
+ .from_('embeddings') \
+ .index('documents-openai') \
+ .query(
+ query_vector={'float32': query_embedding.data[0].embedding},
+ topK=5,
+ return_metadata=True
+ )
+
+ # 3. Use vectors to augment LLM prompt
+ context = '\n\n'.join(
+ v.metadata.get('content', '') if v.metadata else ''
+ for v in vector_results.vectors
+ )
+
+ response = openai.chat.completions.create(
+ model='gpt-4',
+ messages=[
+ {
+ 'role': 'system',
+ 'content': f'Use the following context to answer the user\'s question:\n\n{context}'
+ },
+ {
+ 'role': 'user',
+ 'content': user_query
+ }
+ ]
+ )
+
+ return response.choices[0].message.content
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Product recommendations
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
async function recommendProducts(userEmbedding, topK = 5) {
const supabase = createClient(...)
@@ -473,8 +729,51 @@ async function recommendProducts(userEmbedding, topK = 5) {
}
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+def recommend_products(user_embedding, top_k=5):
+ supabase = create_client(...)
+
+ # Find similar products
+ results = supabase.storage.vectors() \
+ .from_('embeddings') \
+ .index('products-openai') \
+ .query(
+ query_vector={'float32': user_embedding},
+ topK=top_k,
+ filter={'in_stock': True},
+ return_metadata=True
+ )
+
+ return [
+ {
+ 'id': result.metadata.get('product_id') if result.metadata else None,
+ 'name': result.metadata.get('name') if result.metadata else None,
+ 'price': result.metadata.get('price') if result.metadata else None,
+ 'similarity': 1 - result.distance if result.distance else 0
+ }
+ for result in results.vectors
+ ]
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Filtering before similarity search
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
// Use metadata filters to reduce search scope
const { data } = await index.queryVectors({
@@ -486,6 +785,23 @@ const { data } = await index.queryVectors({
})
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+# Use metadata filters to reduce search scope
+results = index.query(
+ query_vector=query_vector,
+ topK=100,
+ filter={'category': 'electronics'} # Pre-filter by category
+)
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
## Next steps
- [Store vectors](/docs/guides/storage/vector/storing-vectors)
diff --git a/apps/docs/content/guides/storage/vector/storing-vectors.mdx b/apps/docs/content/guides/storage/vector/storing-vectors.mdx
index d354bf57ad0..9339e77988c 100644
--- a/apps/docs/content/guides/storage/vector/storing-vectors.mdx
+++ b/apps/docs/content/guides/storage/vector/storing-vectors.mdx
@@ -65,6 +65,43 @@ if (error) {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+
+supabase = create_client('https://your-project.supabase.co', 'your-service-key')
+
+# Get bucket and index
+bucket = supabase.storage.vectors().from_('embeddings')
+index = bucket.index('documents-openai')
+
+# Insert vectors
+index.put([
+ {
+ 'key': 'doc-1',
+ 'data': {'float32': [0.1, 0.2, 0.3]}, # ... rest of embedding
+ 'metadata': {
+ 'title': 'Getting Started with Vector Buckets',
+ 'source': 'documentation',
+ },
+ },
+ {
+ 'key': 'doc-2',
+ 'data': {'float32': [0.4, 0.5, 0.6]}, # ... rest of embedding
+ 'metadata': {
+ 'title': 'Advanced Vector Search',
+ 'source': 'blog',
+ },
+ },
+])
+
+print('✓ Vectors stored successfully')
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -160,6 +197,56 @@ for (let i = 0; i < vectors.length; i += 500) {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+from openai import OpenAI
+from datetime import datetime
+
+supabase = create_client('https://your-project.supabase.co', 'your-service-key')
+openai = OpenAI(api_key=os.environ.get('OPENAI_API_KEY'))
+
+# Documents to embed and store
+documents = [
+ {'id': '1', 'title': 'How to Train Your AI', 'content': 'Guide for training models...'},
+ {'id': '2', 'title': 'Vector Search Best Practices', 'content': 'Tips for semantic search...'},
+ {'id': '3', 'title': 'Building RAG Systems', 'content': 'Implementing retrieval-augmented generation...'},
+]
+
+# Generate embeddings
+embeddings_response = openai.embeddings.create(
+ model='text-embedding-3-small',
+ input=[doc['content'] for doc in documents]
+)
+
+# Prepare vectors for storage
+vectors = []
+for doc, embedding_data in zip(documents, embeddings_response.data):
+ vectors.append({
+ 'key': doc['id'],
+ 'data': {'float32': embedding_data.embedding},
+ 'metadata': {
+ 'title': doc['title'],
+ 'source': 'knowledge_base',
+ 'created_at': datetime.now().isoformat(),
+ },
+ })
+
+# Store vectors in batches (max 500 per request)
+bucket = supabase.storage.vectors().from_('embeddings')
+vector_index = bucket.index('documents-openai')
+
+batch_size = 500
+for i in range(0, len(vectors), batch_size):
+ batch = vectors[i:i + batch_size]
+ vector_index.put(batch)
+ print(f'✓ Stored batch {i // batch_size + 1} ({len(batch)} vectors)')
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -223,6 +310,29 @@ if (!error) {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+index = bucket.index('documents-openai')
+
+# Update a vector (same key)
+index.put([
+ {
+ 'key': 'doc-1',
+ 'data': {'float32': [0.15, 0.25, 0.35]}, # ... updated embedding
+ 'metadata': {
+ 'title': 'Getting Started with Vector Buckets - Updated',
+ 'updated_at': datetime.now().isoformat(),
+ },
+ },
+])
+
+print('✓ Vector updated successfully')
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -266,6 +376,20 @@ if (!error) {
```
</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+index = bucket.index('documents-openai')
+
+# Delete specific vectors
+index.delete(['doc-1', 'doc-2'])
+
+print('✓ Vectors deleted successfully')
+```
+
+</TabPanel>
+</$Show>
<TabPanel id="sql" label="SQL (via S3 Vector Wrapper)">
@@ -324,6 +448,15 @@ const { error } = await index.putVectors({ vectors })
For storing large numbers of vectors efficiently:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
import { createClient } from '@supabase/supabase-js'
import fs from 'fs'
@@ -369,12 +502,67 @@ for (let i = 0; i < vectors.length; i += BATCH_SIZE) {
console.log('✓ All vectors stored successfully')
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+import json
+
+supabase = create_client(...)
+index = supabase.storage.vectors().from_('embeddings').index('documents-openai')
+
+# Read embeddings from file
+with open('embeddings.jsonl', 'r') as f:
+ lines = [line.strip() for line in f if line.strip()]
+
+vectors = []
+for line in lines:
+ data = json.loads(line)
+ vectors.append({
+ 'key': data['key'],
+ 'data': {'float32': data['embedding']},
+ 'metadata': data.get('metadata', {})
+ })
+
+# Process in batches
+BATCH_SIZE = 500
+processed = 0
+
+for i in range(0, len(vectors), BATCH_SIZE):
+ batch = vectors[i:i + BATCH_SIZE]
+
+ try:
+ index.put(batch)
+ processed += len(batch)
+ print(f'Progress: {processed}/{len(vectors)}')
+ except Exception as e:
+ print(f'Batch failed at offset {i}: {e}')
+ # Optionally implement retry logic
+
+print('✓ All vectors stored successfully')
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
## Performance optimization
### Batch operations
Always use batch operations for better performance:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
// ❌ Inefficient - Multiple requests
for (const vector of vectors) {
@@ -385,6 +573,23 @@ for (const vector of vectors) {
await index.putVectors({ vectors })
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+# ❌ Inefficient - Multiple requests
+for vector in vectors:
+ index.put([vector])
+
+# ✅ Efficient - Single batch operation
+index.put(vectors)
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Metadata considerations
Keep metadata concise:
diff --git a/apps/docs/content/guides/storage/vector/working-with-indexes.mdx b/apps/docs/content/guides/storage/vector/working-with-indexes.mdx
index 3cf039aea8c..5894a1b5551 100644
--- a/apps/docs/content/guides/storage/vector/working-with-indexes.mdx
+++ b/apps/docs/content/guides/storage/vector/working-with-indexes.mdx
@@ -33,7 +33,16 @@ Think of an index as a table in a traditional database. It has a schema (dimensi
5. Select the distance metric (`cosine`, `euclidean`, or `l2`).
6. Click **Create**.
-### Via JavaScript SDK
+### Via SDK
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
```typescript
import { createClient } from '@supabase/supabase-js'
@@ -57,6 +66,32 @@ if (error) {
}
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+from supabase import create_client
+
+supabase = create_client('https://your-project.supabase.co', 'your-service-key')
+
+bucket = supabase.storage.vectors().from_('embeddings')
+
+# Create an index
+bucket.create_index(
+ index_name='documents-openai',
+ dimension=1536,
+ distance_metric='cosine',
+ data_type='float32'
+)
+
+print('✓ Index created: documents-openai')
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Choosing the right metric
Most modern embedding models work best with **cosine** distance:
@@ -75,6 +110,15 @@ Most modern embedding models work best with **cosine** distance:
Create multiple indexes for different use cases or embedding models:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
const bucket = supabase.storage.vectors.from('embeddings')
@@ -107,6 +151,46 @@ const { data: indexes } = await bucket.listIndexes()
console.log('All indexes:', indexes)
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+bucket = supabase.storage.vectors().from_('embeddings')
+
+# Index for OpenAI embeddings
+bucket.create_index(
+ index_name='documents-openai',
+ dimension=1536,
+ distance_metric='cosine',
+ data_type='float32'
+)
+
+# Index for Cohere embeddings
+bucket.create_index(
+ index_name='documents-cohere',
+ dimension=1024,
+ distance_metric='cosine',
+ data_type='float32'
+)
+
+# Index for different use case
+bucket.create_index(
+ index_name='images-openai',
+ dimension=1536,
+ distance_metric='cosine',
+ data_type='float32'
+)
+
+# List all indexes
+indexes = bucket.list_indexes()
+print('All indexes:', indexes)
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Use cases for multiple indexes
- **Different embedding models** - Store vectors from OpenAI, Cohere, and local models separately
@@ -118,6 +202,15 @@ console.log('All indexes:', indexes)
### List all indexes in a bucket
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
const bucket = supabase.storage.vectors.from('embeddings')
@@ -132,8 +225,35 @@ if (!error) {
}
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+bucket = supabase.storage.vectors().from_('embeddings')
+
+indexes = bucket.list_indexes()
+
+if indexes:
+ for index in indexes.indexes:
+ print(f'Index: {index.indexName}')
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Get index details
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
const { data: indexDetails, error } = await bucket.getIndex('documents-openai')
@@ -145,10 +265,36 @@ if (!error && indexDetails) {
}
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+index_details = bucket.get_index('documents-openai')
+
+if index_details:
+ print(f'Index: {index_details.index.index_name}')
+ print(f'Dimension: {index_details.index.dimension}')
+ print(f'Distance metric: {index_details.index.distance_metric}')
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
## Deleting indexes
Delete an index to free storage space:
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
const bucket = supabase.storage.vectors.from('embeddings')
@@ -161,6 +307,22 @@ if (error) {
}
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+bucket = supabase.storage.vectors().from_('embeddings')
+
+bucket.delete_index('documents-openai')
+
+print('✓ Index deleted successfully')
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
### Before deleting an index
**Warning**: Deleting an index is permanent and cannot be undone.
@@ -180,6 +342,15 @@ Once created, these properties **cannot be changed**:
### Optimizing index performance
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="javascript"
+ queryGroup="language"
+>
+<TabPanel id="javascript" label="JavaScript">
+
```typescript
// Good - Appropriate batch size
const batch = vectors.slice(0, 250)
@@ -205,6 +376,38 @@ const { data } = await index.queryVectors({
})
```
+</TabPanel>
+<$Show if="sdk:python">
+<TabPanel id="python" label="Python">
+
+```python
+# Good - Appropriate batch size
+batch = vectors[:250]
+index.put(batch)
+
+# Good - Filter metadata before query
+results = index.query(
+ query_vector=query_vector,
+ topK=5,
+ filter={'category': 'electronics'}
+)
+
+# Avoid - Single vector inserts
+for vector in vectors:
+ index.put([vector])
+
+# Avoid - Returning unnecessary data
+results = index.query(
+ query_vector=query_vector,
+ topK=1000, # Too many results
+ return_data=True # Include large embeddings
+)
+```
+
+</TabPanel>
+</$Show>
+</Tabs>
+
## Next steps
- [Store vectors in indexes](/docs/guides/storage/vector/storing-vectors)
diff --git a/apps/docs/spec/supabase_py_v2.yml b/apps/docs/spec/supabase_py_v2.yml
index c95074c8875..8574841e20a 100644
--- a/apps/docs/spec/supabase_py_v2.yml
+++ b/apps/docs/spec/supabase_py_v2.yml
@@ -2815,6 +2815,215 @@ functions:
}
)
```
+
+ - id: oauth-admin-api
+ title: 'Overview'
+ notes: |
+ - OAuth 2.1 client administration endpoints are available via the `supabase.auth.admin.oauth` namespace.
+ - These methods require a `service_role` key and should only be called server-side.
+ - Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
+ - This is an alpha feature and may change in the future.
+
+ - id: auth-js-gotrueadminoauthapi-listclients
+ title: 'admin.oauth.list_clients()'
+ description: |
+ Lists OAuth clients with optional pagination.
+ notes: |
+ - Requires `service_role` key.
+ - Only available when OAuth 2.1 server is enabled.
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: params
+ isOptional: true
+ type: PageParams
+ description: Optional pagination parameters.
+ subContent:
+ - name: page
+ isOptional: true
+ type: number
+ description: Page number (1-indexed).
+ - name: per_page
+ isOptional: true
+ type: number
+ description: Number of items per page.
+ examples:
+ - id: list-oauth-clients
+ name: List OAuth clients
+ code: |
+ ```python
+ response = supabase.auth.admin.oauth.list_clients()
+ ```
+ - id: list-oauth-clients-paginated
+ name: List OAuth clients with pagination
+ code: |
+ ```python
+ response = supabase.auth.admin.oauth.list_clients(
+ params={"page": 1, "per_page": 10}
+ )
+ ```
+
+ - id: auth-js-gotrueadminoauthapi-createclient
+ title: 'admin.oauth.create_client()'
+ description: |
+ Creates a new OAuth client.
+ notes: |
+ - Requires `service_role` key.
+ - Only available when OAuth 2.1 server is enabled.
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: params
+ isOptional: false
+ type: CreateOAuthClientParams
+ description: Parameters for creating a new OAuth client.
+ subContent:
+ - name: name
+ isOptional: false
+ type: string
+ description: The name of the OAuth client.
+ - name: redirect_uris
+ isOptional: false
+ type: list[string]
+ description: List of allowed redirect URIs.
+ - name: grant_types
+ isOptional: true
+ type: list[string]
+ description: List of allowed grant types.
+ - name: response_types
+ isOptional: true
+ type: list[string]
+ description: List of allowed response types.
+ - name: client_type
+ isOptional: true
+ type: string
+ description: The client type.
+ - name: registration_type
+ isOptional: true
+ type: string
+ description: The registration type.
+ examples:
+ - id: create-oauth-client
+ name: Create OAuth client
+ code: |
+ ```python
+ response = supabase.auth.admin.oauth.create_client(
+ {
+ "name": "My OAuth Client",
+ "redirect_uris": ["https://example.com/callback"]
+ }
+ )
+ ```
+
+ - id: auth-js-gotrueadminoauthapi-updateclient
+ title: 'admin.oauth.update_client()'
+ description: |
+ Updates an existing OAuth client.
+ notes: |
+ - Requires `service_role` key.
+ - Only available when OAuth 2.1 server is enabled.
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: client_id
+ isOptional: false
+ type: string
+ description: The ID of the OAuth client to update.
+ - name: params
+ isOptional: false
+ type: UpdateOAuthClientParams
+ description: Parameters for updating the OAuth client.
+ subContent:
+ - name: name
+ isOptional: true
+ type: string
+ description: The name of the OAuth client.
+ - name: redirect_uris
+ isOptional: true
+ type: list[string]
+ description: List of allowed redirect URIs.
+ - name: grant_types
+ isOptional: true
+ type: list[string]
+ description: List of allowed grant types.
+ - name: response_types
+ isOptional: true
+ type: list[string]
+ description: List of allowed response types.
+ examples:
+ - id: update-oauth-client
+ name: Update OAuth client
+ code: |
+ ```python
+ response = supabase.auth.admin.oauth.update_client(
+ "client-id",
+ {
+ "name": "Updated OAuth Client",
+ "redirect_uris": ["https://example.com/callback", "https://example.com/callback2"]
+ }
+ )
+ ```
+
+ - id: auth-js-gotrueadminoauthapi-getclient
+ title: 'admin.oauth.get_client()'
+ description: |
+ Retrieves details of an OAuth client by ID.
+ notes: |
+ - Requires `service_role` key.
+ - Only available when OAuth 2.1 server is enabled.
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: client_id
+ isOptional: false
+ type: string
+ description: The ID of the OAuth client to retrieve.
+ examples:
+ - id: get-oauth-client
+ name: Get OAuth client
+ code: |
+ ```python
+ response = supabase.auth.admin.oauth.get_client("client-id")
+ ```
+
+ - id: auth-js-gotrueadminoauthapi-deleteclient
+ title: 'admin.oauth.delete_client()'
+ description: |
+ Deletes an OAuth client.
+ notes: |
+ - Requires `service_role` key.
+ - Only available when OAuth 2.1 server is enabled.
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: client_id
+ isOptional: false
+ type: string
+ description: The ID of the OAuth client to delete.
+ examples:
+ - id: delete-oauth-client
+ name: Delete OAuth client
+ code: |
+ ```python
+ supabase.auth.admin.oauth.delete_client("client-id")
+ ```
+
+ - id: auth-js-gotrueadminoauthapi-regenerateclientsecret
+ title: 'admin.oauth.regenerate_client_secret()'
+ description: |
+ Regenerates the client secret for an OAuth client.
+ notes: |
+ - Requires `service_role` key.
+ - Only available when OAuth 2.1 server is enabled.
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: client_id
+ isOptional: false
+ type: string
+ description: The ID of the OAuth client.
+ examples:
+ - id: regenerate-oauth-client-secret
+ name: Regenerate OAuth client secret
+ code: |
+ ```python
+ response = supabase.auth.admin.oauth.regenerate_client_secret("client-id")
+ ```
+
- id: mfa-delete-factor
title: 'mfa.delete_factor()'
params:
@@ -7150,14 +7359,6 @@ functions:
title: 'Overview'
notes: |
This section contains methods for working with File Buckets.
- # - id: analytics-buckets
- # title: 'Overview'
- # notes: |
- # This section contains methods for working with Analytics Buckets.
- # - id: vector-buckets
- # title: 'Overview'
- # notes: |
- # This section contains methods for working with Vector Buckets.
- id: list-buckets
title: 'list_buckets()'
@@ -7765,6 +7966,7 @@ functions:
- name: options
isOptional: true
type: CreateSignedUploadUrlOptions
+ description: Additional options for the upload URL creation.
subContent:
- name: upsert
isOptional: true
@@ -7789,14 +7991,17 @@ functions:
"token": "<TOKEN>"
}
```
- - id: create-signed-url-upsert
- name: Create Signed URL with upsert
+ - id: create-signed-url-with-upsert
+ name: Create Signed URL with upsert option
code: |
```python
response = (
supabase.storage
.from_("avatars")
- .create_signed_upload_url("folder/avatar1.png", {"upsert": "true"})
+ .create_signed_upload_url(
+ "folder/avatar1.png",
+ options={"upsert": "true"}
+ )
)
```
response: |
@@ -8187,3 +8392,530 @@ functions:
)
)
```
+
+ - id: analytics-buckets
+ title: 'Overview'
+ notes: |
+ This section contains methods for working with Analytics Buckets.
+ - Analytics buckets are accessed via the `supabase.storage.analytics()` namespace.
+ - Analytics buckets are used for storing and querying analytics data.
+
+ - id: storageanalytics-createbucket
+ title: 'analytics().create()'
+ description: |
+ Creates a new Analytics bucket.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ - Analytics buckets are used for storing and querying analytics data.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the analytics bucket to create.
+ examples:
+ - id: create-analytics-bucket
+ name: Create analytics bucket
+ code: |
+ ```python
+ response = supabase.storage.analytics().create("analytics-bucket")
+ ```
+ response: |
+ ```json
+ {
+ "name": "analytics-bucket",
+ "type": "ANALYTICS",
+ "created_at": "2024-12-03T18:00:00.000Z",
+ "updated_at": "2024-12-03T18:00:00.000Z"
+ }
+ ```
+
+ - id: storageanalytics-listbuckets
+ title: 'analytics().list()'
+ description: |
+ Lists all Analytics buckets with optional filtering and sorting.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: limit
+ isOptional: true
+ type: number
+ description: Maximum number of buckets to return.
+ - name: offset
+ isOptional: true
+ type: number
+ description: Number of buckets to skip.
+ - name: sort_column
+ isOptional: true
+ type: string
+ description: 'Column to sort by. Options: `id`, `name`, `created_at`, `updated_at`.'
+ - name: sort_order
+ isOptional: true
+ type: string
+ description: 'Sort order. Options: `asc`, `desc`.'
+ - name: search
+ isOptional: true
+ type: string
+ description: Search term to filter buckets by name.
+ examples:
+ - id: list-analytics-buckets
+ name: List analytics buckets
+ code: |
+ ```python
+ response = supabase.storage.analytics().list()
+ ```
+ response: |
+ ```json
+ [
+ {
+ "name": "analytics-bucket",
+ "type": "ANALYTICS",
+ "created_at": "2024-12-03T18:00:00.000Z",
+ "updated_at": "2024-12-03T18:00:00.000Z"
+ }
+ ]
+ ```
+
+ - id: storageanalytics-deletebucket
+ title: 'analytics().delete()'
+ description: |
+ Deletes an Analytics bucket.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the analytics bucket to delete.
+ examples:
+ - id: delete-analytics-bucket
+ name: Delete analytics bucket
+ code: |
+ ```python
+ response = supabase.storage.analytics().delete("analytics-bucket")
+ ```
+ response: |
+ ```json
+ {
+ "message": "Successfully deleted"
+ }
+ ```
+
+ - id: vector-buckets
+ title: 'Overview'
+ notes: |
+ This section contains methods for working with Vector Buckets.
+
+ - id: storagevectors-create-bucket
+ title: 'vectors().create_bucket()'
+ description: |
+ Creates a new Vector bucket.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ - Vector buckets are used for storing and querying vector embeddings.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket to create.
+ examples:
+ - id: create-vector-bucket
+ name: Create vector bucket
+ code: |
+ ```python
+ supabase.storage.vectors().create_bucket("vectors-bucket")
+ ```
+
+ - id: storagevectors-get-bucket
+ title: 'vectors().get_bucket()'
+ description: |
+ Retrieves details of a Vector bucket.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket to retrieve.
+ examples:
+ - id: get-vector-bucket
+ name: Get vector bucket
+ code: |
+ ```python
+ response = supabase.storage.vectors().get_bucket("vectors-bucket")
+ ```
+ response: |
+ ```json
+ {
+ "vectorBucket": {
+ "vectorBucketName": "vectors-bucket",
+ "creationTime": "2024-12-03T18:00:00.000Z"
+ }
+ }
+ ```
+
+ - id: storagevectors-list-buckets
+ title: 'vectors().list_buckets()'
+ description: |
+ Lists all Vector buckets with optional pagination.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: prefix
+ isOptional: true
+ type: string
+ description: Filter buckets by name prefix.
+ - name: max_results
+ isOptional: true
+ type: number
+ description: Maximum number of buckets to return.
+ - name: next_token
+ isOptional: true
+ type: string
+ description: Token for pagination.
+ examples:
+ - id: list-vector-buckets
+ name: List vector buckets
+ code: |
+ ```python
+ response = supabase.storage.vectors().list_buckets()
+ ```
+ response: |
+ ```json
+ {
+ "vectorBuckets": [
+ {
+ "vectorBucketName": "vectors-bucket"
+ }
+ ],
+ "nextToken": null
+ }
+ ```
+
+ - id: storagevectors-delete-bucket
+ title: 'vectors().delete_bucket()'
+ description: |
+ Deletes a Vector bucket.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket to delete.
+ examples:
+ - id: delete-vector-bucket
+ name: Delete vector bucket
+ code: |
+ ```python
+ supabase.storage.vectors().delete_bucket("vectors-bucket")
+ ```
+
+ - id: vectorbucket-createindex
+ title: 'vectors().from_().create_index()'
+ description: |
+ Creates a new vector index in a vector bucket.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index to create.
+ - name: dimension
+ isOptional: false
+ type: number
+ description: The dimension of the vectors in this index.
+ - name: distance_metric
+ isOptional: false
+ type: string
+ description: 'The distance metric to use. Options: `cosine`, `euclidean`.'
+ - name: data_type
+ isOptional: false
+ type: string
+ description: The data type of the vectors.
+ - name: metadata
+ isOptional: true
+ type: MetadataConfiguration
+ description: Optional metadata configuration for the index.
+ examples:
+ - id: create-vector-index
+ name: Create vector index
+ code: |
+ ```python
+ supabase.storage.vectors().from_("vectors-bucket").create_index(
+ index_name="my-index",
+ dimension=128,
+ distance_metric="cosine",
+ data_type="float32"
+ )
+ ```
+
+ - id: vectorbucket-getindex
+ title: 'vectors().from_().get_index()'
+ description: |
+ Retrieves details of a vector index.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index to retrieve.
+ examples:
+ - id: get-vector-index
+ name: Get vector index
+ code: |
+ ```python
+ response = supabase.storage.vectors().from_("vectors-bucket").get_index("my-index")
+ ```
+
+ - id: vectorbucket-listindexes
+ title: 'vectors().from_().list_indexes()'
+ description: |
+ Lists all indexes in a vector bucket.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: next_token
+ isOptional: true
+ type: string
+ description: Token for pagination.
+ - name: max_results
+ isOptional: true
+ type: number
+ description: Maximum number of indexes to return.
+ - name: prefix
+ isOptional: true
+ type: string
+ description: Filter indexes by name prefix.
+ examples:
+ - id: list-vector-indexes
+ name: List vector indexes
+ code: |
+ ```python
+ response = supabase.storage.vectors().from_("vectors-bucket").list_indexes()
+ ```
+
+ - id: vectorbucket-deleteindex
+ title: 'vectors().from_().delete_index()'
+ description: |
+ Deletes a vector index.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index to delete.
+ examples:
+ - id: delete-vector-index
+ name: Delete vector index
+ code: |
+ ```python
+ supabase.storage.vectors().from_("vectors-bucket").delete_index("my-index")
+ ```
+
+ - id: vectorindex-putvectors
+ title: 'vectors().from_().index().put()'
+ description: |
+ Inserts or updates vectors in an index.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index.
+ - name: vectors
+ isOptional: false
+ type: list[VectorObject]
+ description: List of vector objects to insert or update.
+ examples:
+ - id: put-vectors
+ name: Put vectors
+ code: |
+ ```python
+ supabase.storage.vectors().from_("vectors-bucket").index("my-index").put([
+ {
+ "key": "vector-1",
+ "data": {"float32": [0.1, 0.2, 0.3]},
+ "metadata": {"category": "example"}
+ }
+ ])
+ ```
+
+ - id: vectorindex-getvectors
+ title: 'vectors().from_().index().get()'
+ description: |
+ Retrieves vectors by their keys.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index.
+ - name: keys
+ isOptional: false
+ type: list[string]
+ description: List of vector keys to retrieve.
+ - name: return_data
+ isOptional: true
+ type: bool
+ description: Whether to return vector data. Defaults to `true`.
+ - name: return_metadata
+ isOptional: true
+ type: bool
+ description: Whether to return metadata. Defaults to `true`.
+ examples:
+ - id: get-vectors
+ name: Get vectors
+ code: |
+ ```python
+ response = supabase.storage.vectors().from_("vectors-bucket").index("my-index").get("vector-1")
+ ```
+
+ - id: vectorindex-listvectors
+ title: 'vectors().from_().index().list()'
+ description: |
+ Lists vectors in an index with optional pagination.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index.
+ - name: max_results
+ isOptional: true
+ type: number
+ description: Maximum number of vectors to return.
+ - name: next_token
+ isOptional: true
+ type: string
+ description: Token for pagination.
+ - name: return_data
+ isOptional: true
+ type: bool
+ description: Whether to return vector data. Defaults to `true`.
+ - name: return_metadata
+ isOptional: true
+ type: bool
+ description: Whether to return metadata. Defaults to `true`.
+ - name: segment_count
+ isOptional: true
+ type: number
+ description: Number of segments for distributed queries.
+ - name: segment_index
+ isOptional: true
+ type: number
+ description: Segment index for distributed queries.
+ examples:
+ - id: list-vectors
+ name: List vectors
+ code: |
+ ```python
+ response = supabase.storage.vectors().from_("vectors-bucket").index("my-index").list()
+ ```
+
+ - id: vectorindex-queryvectors
+ title: 'vectors().from_().index().query()'
+ description: |
+ Queries vectors using a query vector to find similar vectors.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index.
+ - name: query_vector
+ isOptional: false
+ type: VectorData
+ description: The query vector to search with.
+ - name: topK
+ isOptional: true
+ type: number
+ description: Number of results to return.
+ - name: filter
+ isOptional: true
+ type: VectorFilter
+ description: Optional filter to apply to the query.
+ - name: return_distance
+ isOptional: true
+ type: bool
+ description: Whether to return distance scores. Defaults to `true`.
+ - name: return_metadata
+ isOptional: true
+ type: bool
+ description: Whether to return metadata. Defaults to `true`.
+ examples:
+ - id: query-vectors
+ name: Query vectors
+ code: |
+ ```python
+ response = supabase.storage.vectors().from_("vectors-bucket").index("my-index").query(
+ query_vector={"float32": [0.1, 0.2, 0.3]},
+ topK=10
+ )
+ ```
+
+ - id: vectorindex-deletevectors
+ title: 'vectors().from_().index().delete()'
+ description: |
+ Deletes vectors by their keys.
+ notes: |
+ - This is an alpha feature and may change in the future.
+ - Keys batch size must be between 1 and 500.
+ params:
+ - name: bucket_name
+ isOptional: false
+ type: string
+ description: The name of the vector bucket.
+ - name: index_name
+ isOptional: false
+ type: string
+ description: The name of the index.
+ - name: keys
+ isOptional: false
+ type: list[string]
+ description: List of vector keys to delete. Must contain between 1 and 500 keys.
+ examples:
+ - id: delete-vectors
+ name: Delete vectors
+ code: |
+ ```python
+ supabase.storage.vectors().from_("vectors-bucket").index("my-index").delete(["vector-1", "vector-2"])
+ ```