⚠️ Note:For Windows users, we recommend using the pgai Docker image to run the pgai extension. These instructions have only been tested on macOS and Linux.
To install pgai from source on a PostgreSQL server:
-
Install the prerequisite software system-wide
-
PostgreSQL: Version 16 or newer is required.
-
Python3: if running
python3 --version
in Terminal returnscommand not found
, download and install the latest version of Python3. -
Pip: if running
pip --version
in Terminal returnscommand not found
, install it with one of the pip supported methods. -
PL/Python: follow How to install Postgres 16 with plpython3u: Recipes for macOS, Ubuntu, Debian, CentOS, Docker.
macOS: the standard PostgreSQL brew in Homebrew does not include the
plpython3
extension. These instructions show how to install from an alternate tap.-
Postgresql plugin for the asdf version manager: set the
--with-python
option when installing PostgreSQL:POSTGRES_EXTRA_CONFIGURE_OPTIONS=--with-python asdf install postgres 16.3
-
-
pgvector: follow the install instructions from the official repository. This extension is automatically added to your PostgreSQL database when you install the pgai extension.
-
-
Clone the pgai repo at the latest tagged release:
git clone https://github.com/timescale/pgai.git --branch extension-0.6.0 cd pgai
-
Install the
pgai
PostgreSQL extension:just ext install
We use just to run project commands. If you don't have just you can install the extension with:
projects/extension/build.py install
-
Connect to your database with a postgres client like psql v16 or PopSQL.
psql -d "postgres://<username>:<password>@<host>:<port>/<database-name>"
-
Create the pgai extension:
CREATE EXTENSION IF NOT EXISTS ai CASCADE;
The
CASCADE
automatically installspgvector
andplpython3u
extensions.