To use AIDB, add it to shared_preload_libraries, create the extensions in the database, manage user access, and verify the installation. This page also covers proxy settings and the AIDB configuration parameters (GUCs) you can tune afterward.
Configure shared_preload_libraries
In the
postgresql.conffile, addaidbto theshared_preload_librariesparameter:shared_preload_libraries = 'aidb'
Note
If
shared_preload_librariesalready has other extensions listed, appendaidbusing a comma separator. The order doesn't matter.Restart Postgres.
Create the extensions
Create the AIDB extension in your database:
CREATE EXTENSION aidb CASCADE;
The
CASCADEoption automatically installs the requiredvectorextension if it isn't already present.PGD users
If you're running EDB Postgres Distributed (PGD), run the following after creating the extension to register AIDB catalog tables in the replication set:
SELECT aidb.bdr_setup();
If you plan to use external data sources such as S3-compatible object stores or local file system volumes, also install the Postgres File System (PGFS) extension:
CREATE EXTENSION pgfs;
For more information, see PGFS documentation.
Manage user access with the aidb_users role
When you create the AIDB extension, Postgres automatically creates a role named aidb_users. Grant a user membership in this role to give it access to AIDB's SQL functions. This role isn't removed if you later drop the extension.
aidb_users is designed to simplify access management for AIDB features:
- Purpose: Granting a user the
aidb_usersrole gives it access to all AIDB functions, so it can use the extension's capabilities. - Security: The
aidb_usersrole doesn't grant access to AIDB's internal tables, so only the extension's public API is exposed to users who hold it. - Background workers: When background workers are used, they execute as the user who defined them, or as a role specified by the user, provided that user has access to that role.
To let a user use AIDB functions, grant them the aidb_users role:
GRANT aidb_users TO your_user;
For example, create a role named alice with no privileges or role membership to start with:
CREATE ROLE alice LOGIN PASSWORD 'change_me'; -- replace with a real password
Then add alice to the aidb_users role:
GRANT aidb_users TO alice;
alice now inherits whatever privileges aidb_users has, for example EXECUTE on routines in the aidb schema.
Membership in aidb_users doesn't grant access to your own data. Give alice (not aidb_users) the privileges it needs on the tables AIDB will read or write. This example grants access to three arbitrary tables that would ordinarily be source tables used in a pipeline:
GRANT SELECT, INSERT, UPDATE, DELETE ON public.documents, public.email_text, public.chats TO alice;
If alice also needs to create objects in the public schema:
GRANT CREATE ON SCHEMA public TO alice;
Using AIDB through Pipeline Designer
If you access AIDB through Hybrid Manager's Pipeline Designer, pipeline operations run under a separate role, visual_pipeline_user, which must also be granted membership in aidb_users. See VPU and permissions for that setup.
Proxy settings
If your environment routes outbound HTTP traffic through a proxy, set the HTTP_PROXY and HTTPS_PROXY environment variables in the Postgres environment file. On Ubuntu with community Postgres, this file is at /etc/postgresql/<version>/main/environment:
echo "HTTP_PROXY = 'http://<your-proxy-settings>/'" | sudo tee -a /etc/postgresql/16/main/environment echo "HTTPS_PROXY = 'http://<your-proxy-settings>/'" | sudo tee -a /etc/postgresql/16/main/environment
Then restart Postgres for the changes to take effect:
sudo systemctl restart postgresql@16-mainReplace <your-proxy-settings> with your proxy address, and 16 with your Postgres version. Consult the documentation for your Postgres distribution for the exact location of the environment file.
Note
Air-gapped environments aren't currently supported.
Configuration parameters
AIDB exposes a set of Postgres configuration parameters (GUCs) in the aidb.* namespace. Set them in postgresql.conf, per-session with SET, or per-connection with -c. Most parameters below are USERSET — any role can change them for its own session; parameters with a different context are called out individually.
Threading limits
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
aidb.max_threads | integer | 0 | 0–1024 | Maximum number of CPU threads used for local model inference (Candle and llama.cpp). 0 uses the default: half of the available CPUs. SUSET. |
aidb.max_io_threads | integer | 0 | 0–1024 | Maximum number of threads for AIDB's async I/O runtimes (remote model HTTP calls, and volume/object-store I/O). 0 falls back to the TOKIO_WORKER_THREADS environment variable, or Tokio's own default (one per CPU) if that isn't set either. SUSET. |
Both apply live: a session-local SET takes effect immediately in that backend only. Setting either with ALTER SYSTEM or in postgresql.conf takes effect after pg_reload_conf() (or SIGHUP), and propagates to all backends and background workers — no restart required.
aidb.max_threads
SET aidb.max_threads = 4;
aidb.max_io_threads
SET aidb.max_io_threads = 4;
See Threading limits for what these two parameters control, how they interact, and when to lower them.
Model download
The following parameters control how AIDB downloads local model files from HuggingFace (see Local models for applicable providers).
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
aidb.download_log_level | string | notice | — | Controls the output channel for routine download progress messages (for example, download start/complete, byte-progress heartbeats, and adapter load lines). Valid values: notice, log, off. See below. |
aidb.download_max_attempts | integer | 30 | 1–500 | Maximum total download attempts per file (initial request plus retries) before AIDB aborts. See Local model downloads for the retry behavior. |
aidb.download_log_level
Controls where routine download-progress messages are sent. Warnings and errors are unaffected.
| Value | Behavior |
|---|---|
notice | Send messages to the client at NOTICE level. Useful for interactive sessions in psql. |
log | Send messages to the server log only (subject to log_min_messages). Use this for batch jobs and tests where the client output needs to be stable across cold and warm caches. |
off | Suppress routine progress messages entirely. |
Example:
SET aidb.download_log_level = 'log';
aidb.download_max_attempts
Caps the total number of download attempts per file. The downloader aborts early when consecutive attempts make zero progress, so this parameter is primarily a safety ceiling against excessive retry loops.
Lower it (for example, to 3 or 5) for fail-fast behavior in CI or scripted batch jobs. Raise it only for very large files on lossy links.
Example:
SET aidb.download_max_attempts = 5;
llama.cpp native logs
| Parameter | Type | Default | Range | Description |
|---|---|---|---|---|
aidb.enable_llamacpp_logs | boolean | false | — | Controls whether llama.cpp's own diagnostic output (GGUF metadata, tensor shapes, and backend/model initialization) is written to the server log. SUSET. Read once at extension initialization — see below. |
aidb.enable_llamacpp_logs
Off by default: llama.cpp's native logging is verbose — hundreds of lines per model load — so it's suppressed unless you need it. This is separate from aidb.download_log_level above, which controls AIDB's own download-progress messages; the two are independent.
Unlike the other parameters on this page, aidb.enable_llamacpp_logs is SUSET (a superuser, or a role granted SET on the parameter, can change it) and is read once when the extension initializes. Setting it with SET, ALTER SYSTEM, or editing postgresql.conf and reloading (pg_reload_conf()) doesn't take effect until Postgres is restarted:
aidb.enable_llamacpp_logs = true
sudo systemctl restart postgresql@16-mainApplies only to llamacpp_generate and llamacpp_embeddings models — it has no effect on Candle-based models (bert_local, clip_local, t5_local, llama_instruct_local). See Local models — Troubleshooting for when to use this.
Network egress
The following parameter restricts outbound HTTP traffic from AIDB — both calls to model provider APIs and model file downloads from HuggingFace. When unset, no restriction is applied and AIDB can reach any host.
| Parameter | Type | Default | Description |
|---|---|---|---|
aidb.egress_allowlist | string | unset | Comma-separated list of hosts and/or CIDR ranges that AIDB is allowed to reach. When set, any outbound request to a destination not on the list is rejected before the connection is made. |
edb.egress_allowlist | string | unset | Shared fallback allowlist used by all EDB extensions when the per-extension aidb.egress_allowlist is not set. Useful when AIDB and other EDB extensions (such as PGFS) share the same network policy. |
Entry format
Each comma-separated entry is one of:
| Form | Matches |
|---|---|
host.example.com | Exact hostname match (case-insensitive). |
.example.com | Any subdomain of example.com (doesn't match example.com itself). |
203.0.113.10 | Exact IPv4 or IPv6 literal in the destination URL. |
203.0.113.0/24 | IPv4 CIDR range; matches IP literals in that range. Doesn't match hostnames. |
2001:db8::/32 | IPv6 CIDR range. |
Whitespace around entries is ignored. CIDR entries are checked only against IP literals — hostnames aren't resolved for matching.
Resolution order
For each outbound request, AIDB checks aidb.egress_allowlist first. If it isn't set, AIDB falls back to edb.egress_allowlist. If neither is set, no check is applied. Redirects (for example, HuggingFace redirecting to a CDN host) are re-checked against the same allowlist; a redirect to a host not on the list is rejected.
Example
Allow only direct calls to OpenAI and HuggingFace plus its CDN:
aidb.egress_allowlist = 'api.openai.com, huggingface.co, .huggingface.co, cdn-lfs.huggingface.co'
When a request is rejected, AIDB raises an error that names the active parameter so the operator can adjust the list.
Note
PGFS implements the same allowlist mechanism under pgfs.egress_allowlist, applied to traffic from PGFS to cloud object-store endpoints (S3, Google Cloud Storage, Azure Blob). edb.egress_allowlist is the shared fallback for both extensions: set it to apply one list to AIDB and PGFS together, or use the per-extension parameters when each needs a different policy. See PGFS — Network egress.
If your AIDB pipelines read from external storage, both allowlists are relevant: AIDB's controls model-provider and HuggingFace traffic, and PGFS's controls the connection to your object store. See External storage for how AIDB and PGFS work together.
Validate the installation
Confirm that the extensions are installed by running \dx in psql and looking for aidb, vector, pgfs (if installed), in the output:
aidb=# \dx
List of installed extensions
Name | Version | Schema | Description
-----------------------+---------+------------+------------------------------------------------------------
aidb | 7.4.0 | aidb | aidb: makes it easy to build AI applications with postgres
pgfs | 1.0.6 | pgfs | pgfs: enables access to filesystem-like storage locations
vector | 0.8.0 | public | vector data type and ivfflat and hnsw access methods