---
title: pgai documentation | Tiger Data Docs
description: A Python library that turns PostgreSQL into the retrieval engine behind robust, production-ready RAG and Agentic applications.
---

# pgai documentation

A Python library that turns PostgreSQL into the retrieval engine behind robust, production-ready RAG and Agentic applications.

- 🔄 Automatically create vector embeddings from data in PostgreSQL tables as well as documents in S3. The embeddings are automatically updated as the 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.

## pgai install

The pgai python library can be installed using pip:

Terminal window

```
pip install pgai
```

To setup the necessary database functions and tables in your PostgreSQL database, run the following python code:

```
from pgai
pgai.install(DB_URL)
```

All of the pgai objects are installed into the `ai` schema.

## pgai Vectorizer

Vectorizer automates the embedding process within your database management by treating embeddings as a declarative, DDL-like feature, like an index.

**Overview**: [Automate AI embedding with pgai Vectorizer](/docs/reference/pgai/vectorizer/overview/index.md) - a comprehensive overview of Vectorizer features, demonstrating how it streamlines the process of working with vector embeddings in your database.

- **Quickstart guides**:

  - [Vectorizer quickstart for Ollama](/docs/reference/pgai/vectorizer/quick-start/index.md): setup your developer environment, create and run a vectorizer.
  - [Vectorizer quickstart for OpenAI](/docs/reference/pgai/vectorizer/quick-start-openai/index.md): setup your developer environment, create and run a vectorizer using OpenAI.
  - [Vectorizer quickstart for Voyage](/docs/reference/pgai/vectorizer/quick-start-voyage/index.md): setup your developer environment, create and run a vectorizer using Voyage.

- **References**:

  - [pgai Vectorizer API reference](/docs/reference/pgai/vectorizer/api-reference/index.md): API reference for Vectorizer functions
  - [Documentation for vectorizer worker](/docs/reference/pgai/vectorizer/worker/index.md): explain how to run vectorizers on a self-hosted PostgreSQL instance.
  - [SqlAlchemy and Alembic integration](/docs/reference/pgai/vectorizer/python-integration/index.md): learn how to use Vectorizer with SqlAlchemy and Alembic.

- **Develop**:
  - [Add a Vectorizer embedding integration](/docs/reference/pgai/vectorizer/adding-embedding-integration/index.md)

## pgai utils

- [Chunking](/docs/reference/pgai/utils/chunking/index.md): chunking algorithms you can use from within SQL.

## pgai extension

The pgai extension is a PostgreSQL extension that performs model calling inside of PostgreSQL. You can find more information about the extension in the [pgai extension documentation](/docs/reference/pgai/extension/index.md).
