AI workflows in your PostgreSQL database
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pgai-0.12.1.tar.gz.
File metadata
- Download URL: pgai-0.12.1.tar.gz
- Upload date:
- Size: 18.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c73008713301995345bfa1e3f8fa93628ed46991cd4ccbcee6696c0838208b10
|
|
| MD5 |
79bce44f419702eea9d3c5ae06629d27
|
|
| BLAKE2b-256 |
5e6495e53a596ab1cbaa6662c3b447b25bdeb3cc05ff46b7941553cb95b4df50
|
Provenance
The following attestation bundles were made for pgai-0.12.1.tar.gz:
Publisher:
release-please.yml on timescale/pgai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgai-0.12.1.tar.gz -
Subject digest:
c73008713301995345bfa1e3f8fa93628ed46991cd4ccbcee6696c0838208b10 - Sigstore transparency entry: 603650728
- Sigstore integration time:
-
Permalink:
timescale/pgai@c1a7959f92ad005e2097b18f0b5ff7457604edd0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/timescale
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@c1a7959f92ad005e2097b18f0b5ff7457604edd0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pgai-0.12.1-py3-none-any.whl.
File metadata
- Download URL: pgai-0.12.1-py3-none-any.whl
- Upload date:
- Size: 3.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16f38e891d251472c69cc34aea5177d5c0f5309ddf1a6f79699eb3ec6310a2ee
|
|
| MD5 |
02e4b8db97a5e012bd5a70baa849b939
|
|
| BLAKE2b-256 |
c60dadca8d6416954232641a93708bc3b4e1caa7b5fa866aa9f61f94faefa7c3
|
Provenance
The following attestation bundles were made for pgai-0.12.1-py3-none-any.whl:
Publisher:
release-please.yml on timescale/pgai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pgai-0.12.1-py3-none-any.whl -
Subject digest:
16f38e891d251472c69cc34aea5177d5c0f5309ddf1a6f79699eb3ec6310a2ee - Sigstore transparency entry: 603650784
- Sigstore integration time:
-
Permalink:
timescale/pgai@c1a7959f92ad005e2097b18f0b5ff7457604edd0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/timescale
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@c1a7959f92ad005e2097b18f0b5ff7457604edd0 -
Trigger Event:
push
-
Statement type: