Skip to main content

pgvector-extension Logo

LocalStack pgvector Extension 🚀

Install LocalStack Extension License: MIT PyPI version

localstack-extension-pgvector is a professional extension for LocalStack designed to simplify the development of AI-driven applications and Vector Search. This extension automatically enables pgvector on every PostgreSQL instance running in LocalStack and provides a web interface via pgweb.


✨ Key Features

  • Auto-Enable pgvector: Automatically executes CREATE EXTENSION IF NOT EXISTS vector; when a PostgreSQL container starts.
  • pgweb Integration: Automatically launches a pgweb (Web UI) instance as a sidecar to visualize your vector data.
  • Seamless Integration: Supports standard RDS and PostgreSQL instances in LocalStack.
  • Health Check Endpoint: Verify extension status via a dedicated HTTP endpoint.

🛠️ Installation

Click the badge above or open the LocalStack Extensions Dashboard and enter this repository URL: https://github.com/Nocturnailed-Community/localstack-extension-pgvector

Using CLI

Use the following command to install the extension locally:

localstack extensions install "https://github.com/Nocturnailed-Community/localstack-extension-pgvector"

Local Development (Editable Mode)

  1. Clone this repository.
  2. Run:
    pip install -e .
    
  3. Restart LocalStack.

🐳 Using Docker Compose

For easy local development, you can use the provided docker-compose.yml:

  1. Start LocalStack:
    docker compose up -d
    
  2. The extension will be installed automatically. Check status:
    curl http://localhost:4566/pgvector-status
    

🛠️ Usage

  1. Start LocalStack:
    localstack start
    
  2. Launch PostgreSQL/RDS: Use AWS CLI or SDK to create a database instance. Example:
    awslocal rds create-db-instance --db-instance-identifier mydb --engine postgres --allocated-storage 20
    
  3. Access pgweb: Open your browser and navigate to http://localhost:8081 to view your data.
  4. Check Status: Verify if the extension is active: http://localhost:4566/pgvector-status

📡 API Reference (v0.2.0)

All endpoints are accessible via http://localhost:4566/pgvector/...

Status

curl http://localhost:4566/pgvector/status

Table Management

List tables:

curl http://localhost:4566/pgvector/tables

Create a table (with vector column):

curl -X POST http://localhost:4566/pgvector/tables \
  -H "Content-Type: application/json" \
  -d '{
    "table_name": "documents",
    "columns": [
      {"name": "id", "type": "SERIAL PRIMARY KEY"},
      {"name": "content", "type": "TEXT"},
      {"name": "embedding", "type": "vector(3)"}
    ]
  }'

Get table schema:

curl http://localhost:4566/pgvector/tables/documents/schema

Drop a table:

curl -X DELETE http://localhost:4566/pgvector/tables/documents

Data Operations

Insert rows:

curl -X POST http://localhost:4566/pgvector/tables/documents/data \
  -H "Content-Type: application/json" \
  -d '{
    "rows": [
      {"content": "Hello AI", "embedding": "[1,2,3]"},
      {"content": "Vector DB", "embedding": "[4,5,6]"}
    ]
  }'

Get rows (with pagination):

curl "http://localhost:4566/pgvector/tables/documents/data?limit=10&offset=0"

Update rows:

curl -X PUT http://localhost:4566/pgvector/tables/documents/data \
  -H "Content-Type: application/json" \
  -d '{"set": {"content": "Updated"}, "where": "id = 1"}'

Delete rows:

curl -X DELETE http://localhost:4566/pgvector/tables/documents/data \
  -H "Content-Type: application/json" \
  -d '{"where": "id = 1"}'

Raw SQL Query

curl -X POST http://localhost:4566/pgvector/query \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT * FROM pg_extension WHERE extname = '\''vector'\'';"}'
curl -X POST http://localhost:4566/pgvector/search \
  -H "Content-Type: application/json" \
  -d '{
    "table_name": "documents",
    "column": "embedding",
    "query_vector": [1, 2, 3],
    "distance": "cosine",
    "limit": 5
  }'

Supported distance metrics: cosine, l2, inner_product


👨‍💻 Contributors


📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❤️ by Noc Lab as part of the LocalStack ecosystem.

Metadata

Release files for localstack-extension-pgvector 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for localstack-extension-pgvector 0.2.0
File Size Uploaded
localstack_extension_pgvector-0.2.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for localstack-extension-pgvector 0.2.0
File Interpreter ABI Platform
localstack_extension_pgvector-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / localstack_extension_pgvector-0.2.0.tar.gz

Download URL localstack_extension_pgvector-0.2.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f6732826dc22db7ddc7c8077fe5edfe2baeff0309cb4c962c227280c2b42e528
BLAKE2b-256 checksum
How to use checksums
ae192861bdac141b52ff2e82bcaddcc41244f59a05da0bffff7bea433091c215
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release files / localstack_extension_pgvector-0.2.0-py3-none-any.whl

Download URL localstack_extension_pgvector-0.2.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ec130749c4a21b37179cd6c1a706f7ae5d884837b225e73e3e63d77d3665006
BLAKE2b-256 checksum
How to use checksums
3fb751c551da7197e544f39e729fbc1f4e1f20badc49588c593c907adaa1e042
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page