
AI PostgreSQL
CertifiedPersist chat memory in PostgreSQL
AI PostgreSQL
Persist chat memory in PostgreSQL
Stores chat history in a PostgreSQL table keyed by memory_id; TTL sets an expires_at timestamp. Honors drop policies BEFORE_TASKRUN/AFTER_TASKRUN; defaults to NEVER (memory is retained). Table is created if missing. Requires reachable Postgres with permissions to create tables.
type: io.kestra.plugin.ai.memory.PostgreSQLExamples
Use PostgreSQL-based chat memory for a conversation
id: chat_with_memory
namespace: company.ai
tasks:
- id: first
type: io.kestra.plugin.ai.rag.ChatCompletion
chatProvider:
type: io.kestra.plugin.ai.provider.GoogleGemini
modelName: gemini-3.5-flash-lite
apiKey: "{{ secret('GEMINI_API_KEY') }}"
memory:
type: io.kestra.plugin.ai.memory.PostgreSQL
host: localhost
port: 5432
database: ai_memory
user: postgres
password: secret
tableName: my_custom_memory_table
systemMessage: You are a helpful assistant, answer concisely
prompt: "{{ inputs.first }}"
Properties
database *string
Database name
Name of the PostgreSQL database holding the chat memory table. No default: this property is required.
host *string
PostgreSQL host
Hostname or IP address of the PostgreSQL server storing the chat memory. No default: this property is required.
password *string
Database password
Password of the database user. Store it as a Kestra secret rather than inline. No default: this property is required.
user *string
Database user
User connecting to the PostgreSQL database. No default: this property is required.
drop string
NEVERNEVERBEFORE_TASKRUNAFTER_TASKRUNWhen to drop the memory
Controls when the stored conversation is erased, rather than waiting for ttl to expire. NEVER (default) keeps it until expiry, BEFORE_TASKRUN clears it before the task runs, and AFTER_TASKRUN clears it once the task run completes.
memoryId string
{{ labels.system.correlationId }}Memory ID
Identifier under which the conversation is stored, so that different runs or users can keep separate histories. Defaults to the system.correlationId label, which makes one memory span an entire flow execution including its subflows.
messages integerstring
10Maximum messages in memory
Number of chat messages retained in memory. When the limit is reached, the oldest messages are evicted first (FIFO); the last system message is always kept. Defaults to 10.
port integerstring
5432PostgreSQL port
TCP port the PostgreSQL server listens on. Defaults to 5432.
tableName string
chat_memoryTable name
Table used to persist the chat memory, created with CREATE TABLE IF NOT EXISTS on first use. Must match ^[a-zA-Z_][a-zA-Z0-9_]{0,62}$, or the task fails before connecting; this is enforced to prevent SQL injection, since the name is interpolated into the statements. Defaults to chat_memory.
ttl string
PT1HMemory duration
How long the memory is retained before it expires. Defaults to PT1H (one hour).