Skip to content

PostgreSQL (pgvector)

<dependency>
<groupId>com.google.genkit</groupId>
<artifactId>genkit-plugin-postgresql</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
  • PostgreSQL 12+ with the pgvector extension installed
  • Java 21+
import com.google.genkit.plugins.postgresql.PostgreSQLPlugin;
Genkit genkit = Genkit.builder()
.plugin(PostgreSQLPlugin.create(
"jdbc:postgresql://localhost:5432/mydb",
"user", "password"))
.build();
  • Cosine, L2, and inner product similarity search
  • Automatic schema management
  • Connection pooling
  • Batch indexing
  • Metadata support

The plugin also ships PostgresSessionStore, a PostgreSQL-backed agent session store. Construct it from a javax.sql.DataSource and pass it to an agent’s .store(...) to persist server-managed sessions in PostgreSQL:

import com.google.genkit.plugins.postgresql.session.PostgresSessionStore;
import com.google.genkit.plugins.postgresql.session.PostgresSessionStoreOptions;
PostgresSessionStore<Map<String, Object>> store =
new PostgresSessionStore<>(
dataSource, PostgresSessionStoreOptions.builder().createTableIfNotExists(true).build());

See Session Stores for options and the agents-postgres-session sample.

See the postgresql sample.