Favicon of pgai

pgai

A self-hosted Python library for PostgreSQL RAG and semantic search, with Ollama and cloud embedding providers. Open source, archived and no longer maintained.

pgai keeps search embeddings in sync with PostgreSQL data for developers building RAG applications and AI agents. It's a Python library with database components and workers you can self-host, including in Docker. The project is archived and no longer maintained or supported. Its code is open source under the PostgreSQL License.

The vectorizer creates embeddings from database columns, files and S3 documents, then updates them as the underlying data changes. It can parse PDF, HTML and Markdown documents, split text into chunks, and produce separate embeddings with different models for comparison. Search uses pgvector, with pgvectorscale available for larger vector workloads.

Embedding jobs run separately from ordinary database writes, so a slow or failed model endpoint doesn't block changes to your application data. Batch processing, queues and retries handle provider failures, rate limits and latency spikes. Embeddings and text chunks live in PostgreSQL. Ollama supports local model use; choosing a cloud provider such as OpenAI, Cohere or Voyage AI sends embedding input to that service. The database can be self-hosted or hosted through services including Timescale Cloud, Amazon RDS and Supabase.

The Semantic Catalog supports natural language queries by generating database descriptions that people can review and revise. It also stores SQL examples and business facts to give models context about the data. A separate PostgreSQL extension lets applications call models directly from SQL for classification, summarization and data enrichment.

Similar to pgai