> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with database persistence in 5 minutes

# Persistence Quickstart

Enable automatic conversation persistence with memory configuration.

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install "praisonaiagents[tools]"
```

## Docker Setup

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# PostgreSQL
docker run -d --name praison-postgres -p 5432:5432 \
    -e POSTGRES_PASSWORD=praison123 \
    -e POSTGRES_DB=praisonai \
    postgres:16

# Qdrant (optional - for knowledge)
docker run -d --name praison-qdrant -p 6333:6333 qdrant/qdrant

# Redis (optional - for state)
docker run -d --name praison-redis -p 6379:6379 redis:7
```

## Basic Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

# Create agent with persistence
agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
    memory={
        "db": "postgresql://postgres:praison123@localhost:5432/praisonai",
        "session_id": "my-session-001"
    }
)

# All chats are automatically persisted
response = agent.start("My name is Alice")
print(response)
```

## SQLite (Zero Config)

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    memory={
        "db": "conversations.db",
        "session_id": "local-session"
    }
)
response = agent.start("Hello!")
print(response)
```

## Backend Options

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

# PostgreSQL
agent = Agent(
    name="Bot",
    memory={"db": "postgresql://user:pass@localhost/db"}
)

# SQLite
agent = Agent(
    name="Bot",
    memory={"db": "mydata.db"}
)

# MySQL
agent = Agent(
    name="Bot",
    memory={"db": "mysql://user:pass@localhost/db"}
)
```

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export PRAISON_CONVERSATION_URL="postgresql://localhost/mydb"
export OPENAI_API_KEY="your-key"
```

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import os
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    memory={"db": os.getenv("PRAISON_CONVERSATION_URL")}
)
```

## CLI Usage

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Validate connectivity
praisonai persistence doctor \
    --conversation-url "postgresql://postgres:praison123@localhost/praisonai"

# Run agent with persistence
praisonai persistence run \
    --session-id "cli-session" \
    --conversation-url "postgresql://postgres:praison123@localhost/praisonai" \
    "Hello, my name is Bob"
```

## Continue a Session from the CLI

`praisonai session resume` restores chat history, model, and agent name — then optionally continues with a new prompt:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai session resume cli-session "What was my name again?"
```

## Serverless Database Tuning

For serverless databases that may experience cold starts, tune the retry parameters:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

# PlanetScale MySQL 
agent = Agent(
    name="Assistant",
    memory={
        "db": "mysql://user:pass@gateway.psdb.cloud:3306/mydb",
        "max_retries": 5,      # Higher retries for cold starts
        "retry_delay": 1.0     # Longer initial delay
    }
)

# Neon PostgreSQL
agent = Agent(
    name="Assistant", 
    memory={
        "db": "postgresql://user:pass@host.neon.tech/db",
        "max_retries": 3,
        "retry_delay": 0.5
    }
)
```

Supported serverless platforms with auto-retry:

* **PlanetScale**: `.psdb.cloud` hosts (exponential backoff)
* **Neon**: `.neon.tech` hosts
* **CockroachDB**: `.cockroachlabs.cloud`, `.cockroachlabs.com`
* **Supabase**: `.supabase.com`, `.supabase.co`
* **Xata**: `.xata.sh`

## Next Steps

* [Session Resume](/docs/persistence/session-resume) - Continue conversations
* [Async Conversation Store](/docs/features/async-conversation-store) - Non-blocking persistence
* [PostgreSQL](/docs/databases/postgres) - Production setup
* [CLI Reference](/docs/cli/persistence) - Full CLI documentation
