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

# SurrealDB

> Persist Agno sessions and other data in SurrealDB.

`SurrealDb` stores Agent, Team, and Workflow sessions, memories, knowledge, evaluations, and traces in [SurrealDB](https://surrealdb.com/).

See the [SurrealDB documentation](https://surrealdb.com/docs) for server and connection setup.

## Usage

Install the `surrealdb` and `openai` packages:

```shell theme={null}
uv pip install surrealdb openai
```

### Run SurrealDB

Install [Docker Desktop](https://docs.docker.com/get-started/get-docker/), then start SurrealDB on port `8000`:

```bash theme={null}
docker run --rm --pull always -p 8000:8000 surrealdb/surrealdb:latest start --user root --pass root
```

```python surrealdb_for_agent.py theme={null}
from agno.agent import Agent
from agno.db.surrealdb import SurrealDb

SURREALDB_URL = "ws://localhost:8000"
SURREALDB_USER = "root"
SURREALDB_PASSWORD = "root"
SURREALDB_NAMESPACE = "agno"
SURREALDB_DATABASE = "surrealdb_for_agent"

credentials = {"username": SURREALDB_USER, "password": SURREALDB_PASSWORD}
db = SurrealDb(
    client=None,
    db_url=SURREALDB_URL,
    db_creds=credentials,
    db_ns=SURREALDB_NAMESPACE,
    db_db=SURREALDB_DATABASE,
)

agent = Agent(db=db)
```

## Parameters

<Snippet file="db-surrealdb-params.mdx" />
