Skip to main content
Agno supports using Valkey as a database with the ValkeyDb class.

Usage

Run Valkey

Install docker desktop and run Valkey on port 6379 using:
docker run -d \
  --name my-valkey \
  -p 6379:6379 \
  valkey/valkey
valkey_for_agent.py
from agno.agent import Agent
from agno.db.valkey import ValkeyDb

# Initialize Valkey db
db = ValkeyDb(
    host="localhost",
    port=6379,
)

# Create agent with Valkey db
agent = Agent(db=db)

Params

ParameterTypeDefaultDescription
idOptional[str]-The ID of the database instance. UUID by default.
valkey_clientOptional[Union[GlideClient, GlideClusterClient]]-Pre-configured Valkey GLIDE client. If not provided a new client will be created.
hoststr"localhost"Valkey server host.
portint6379Valkey server port.
database_idOptional[int]-Logical database index (e.g. 0-15).
usernameOptional[str]-Username for authentication.
passwordOptional[str]-Password for authentication.
use_tlsboolFalseEnable TLS encryption.
request_timeoutOptional[int]-Milliseconds to wait for a request to complete. If unset, the GLIDE client default (250 ms) applies.
db_prefixstr"agno"Prefix for all Valkey keys.
client_namestr"agno_db_client"Connection name, visible in CLIENT LIST.
expireOptional[int]-TTL for Valkey keys in seconds.
session_tableOptional[str]-Name of the table to store sessions.
memory_tableOptional[str]-Name of the table to store memories.
metrics_tableOptional[str]-Name of the table to store metrics.
eval_tableOptional[str]-Name of the table to store evaluation runs.
knowledge_tableOptional[str]-Name of the table to store knowledge documents.
traces_tableOptional[str]-Name of the table to store traces.
spans_tableOptional[str]-Name of the table to store spans.
learnings_tableOptional[str]-Name of the table to store learnings.