timescale /pgai

A suite of tools to develop RAG, semantic search, and other AI applications more easily with PostgreSQL

★ 5,792⑂ 319👁 39⑃ 818● 109▤ 43
PLpgSQLPostgreSQLCreated 2024-05-16
下载:extension-0.11.2extension-0.11.2 ↓0.11.22025-10-14
+0
日增长
5,792
stars
319
forks
39
watchers
818
prs
109
issues
43
releases

README

Power your RAG and Agentic applications with PostgreSQL


  Docs ·
  Join the pgai Discord! ·
  Try timescale for free! ·
  Changelog




 As of February 2026, this project is no longer being maintained or supported. 

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.

- 🤖 Semantic Catalog: Enable natural language to SQL with AI. Automatically generate database descriptions and power text-to-SQL for agentic applications. 

- 🔍 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.


Basic Architecture:
The system consists of an application you write, a PostgreSQL database, and stateless vectorizer workers. The application defines a vectorizer configuration to embed data from sources like PostgreSQL or S3. The workers read this configuration, processes the data queue into embeddings and chunked text, and writes the results back. The application then queries this data to power RAG and semantic search.

The key strength of this architecture lies in its resilience: data modifications made by the application are decoupled from the embedding process, ensuring that failures in the embedding service do not affect the core data operations.
    






 install 

First, install the pgai package.

bash
pip install pgai
              

Then, install the pgai database components. You can do this from the terminal using the CLI or in your Python application code using the pgai python package.

 from the cli
pgai install -d 

 or from the python package, often done as part of your application setup
import pgai
pgai.install(DB_URL)


If you are not on Timescale Cloud you will also need to run the pgai vectorizer worker. Install the dependencies for it via:
bash
pip install "pgai[vectorizer-worker]"


If you are using the semantic catalog, you will need to run:

bash
pip install "pgai[semantic-catalog]"



 Quick Start

This quickstart demonstrates how pgai Vectorizer enables semantic search and RAG over PostgreSQL data by automatically creating and synchronizing embeddings as data changes.

Looking for text-to-SQL? Check out the Semantic Catalog quickstart to transform natural language questions into SQL queries.

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:

sql
CREATE TABLE IF NOT EXISTS wiki 

Top issues

Latest release

extension-0.11.2 extension-0.11.2 2025-10-14
What's Changed
 fix: use lockfile for old versions by @alejandrodnm in https://github.com/timescale/pgai/pull/885


Full Changelog: https://github.com/timescale/pgai/compare/pgai-v0.12.1...extension-0.11.2

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON