Power your RAG and Agentic applications with PostgreSQL
A Python library that transforms PostgreSQL into a robust, production-ready retrieval engine for RAG and Agentic applications.
-
🔄 Automatically create and synchronize vector embeddings from PostgreSQL data and S3 documents. Embeddings update automatically as data changes.
-
🔍 Powerful vector and semantic search with pgvector and pgvectorscale.
-
🛡️ Production-ready out-of-the-box: Supports batch processing for efficient embedding generation, with built-in handling for model failures, rate limits, and latency spikes.
-
🐘 Works with any PostgreSQL database, including Timescale Cloud, Amazon RDS, Supabase and more.
Getting Started
Install:
pip install pgai
pgai install -d "postgresql://postgres:postgres@localhost:5432/postgres"
The key "secret sauce" of pgai Vectorizer is its declarative approach to embedding generation. Simply define your pipeline and let Vectorizer handle the operational complexity of keeping embeddings in sync, even when embedding endpoints are unreliable. You can define a simple version of the pipeline as follows:
SELECT ai.create_vectorizer(
'wiki'::regclass,
loading => ai.loading_column(column_name=>'text'),
embedding => ai.embedding_openai(model=>'text-embedding-ada-002', dimensions=>'1536'),
destination => ai.destination_table(target_table=>'wiki_embedding_storage')
)
The vectorizer will automatically create embeddings for all the rows in the
wiki table, and, more importantly, will keep the embeddings synced with the
underlying data as it changes. Think of it almost like declaring an index on
the wiki table, but instead of the database managing the index datastructure
for you, the vectorizer is managing the embeddings.
Checkout our full quick start on github
Metadata
Release files for pgai 0.12.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pgai-0.12.1.tar.gz | 18.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pgai-0.12.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.2 MB
Release files / pgai-0.12.1.tar.gz
| Download URL | pgai-0.12.1.tar.gz |
|---|---|
| Size | 18.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c73008713301995345bfa1e3f8fa93628ed46991cd4ccbcee6696c0838208b10
|
|
BLAKE2b-256 checksum How to use checksums |
5e6495e53a596ab1cbaa6662c3b447b25bdeb3cc05ff46b7941553cb95b4df50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2025.
Transparency logRelease files / pgai-0.12.1-py3-none-any.whl
| Download URL | pgai-0.12.1-py3-none-any.whl |
|---|---|
| Size | 3.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16f38e891d251472c69cc34aea5177d5c0f5309ddf1a6f79699eb3ec6310a2ee
|
|
BLAKE2b-256 checksum How to use checksums |
c60dadca8d6416954232641a93708bc3b4e1caa7b5fa866aa9f61f94faefa7c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2025.
Transparency log