Skip to main content
Most TensorZero deployments will not require Postgres.
TensorZero only requires Postgres for certain advanced features. Most notably, you need to deploy Postgres to run adaptive A/B tests and set up auth for TensorZero.

Deploy

You can self-host Postgres or use a managed service (e.g. AWS RDS, Supabase, PlanetScale). Follow the deployment instructions for your chosen service. Internally, we test TensorZero using self-hosted Postgres 14.
If you find any compatibility issues, please open a detailed GitHub Discussion.

Configure

Connect to Postgres

To configure TensorZero to use Postgres, set the TENSORZERO_POSTGRES_URL environment variable with your Postgres connection details.
.env
TENSORZERO_POSTGRES_URL="postgres://[username]:[password]@[hostname]:[port]/[database]"

# Example:
TENSORZERO_POSTGRES_URL="postgres://myuser:mypass@localhost:5432/tensorzero"

Apply Postgres migrations

Unlike with ClickHouse, TensorZero does not automatically apply Postgres migrations. You must apply migrations manually with gateway --run-postgres-migrations.
If you’ve configured the gateway with Docker Compose, you can run the migrations with:
docker-compose run --rm gateway --run-postgres-migrations
See Deploy the TensorZero Gateway for more details.