> ## 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.

# Valkey for Agent

Agno supports using Valkey as a storage backend for Agents using the `ValkeyDb` class.

## Usage

### Run Valkey

Install [docker desktop](https://docs.docker.com/desktop/install/mac-install/) and run **Valkey** on port **6379** using:

```bash theme={null}
docker run -d \
  --name my-valkey \
  -p 6379:6379 \
  valkey/valkey
```

```python valkey_for_agent.py theme={null}
from agno.agent import Agent
from agno.db.base import SessionType
from agno.db.valkey import ValkeyDb
from agno.tools.hackernews import HackerNewsTools

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

# Create agent with Valkey db
agent = Agent(
    db=db,
    tools=[HackerNewsTools()],
    add_history_to_context=True,
)

agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")

# Verify db contents
print("\nVerifying db contents...")
all_sessions = db.get_sessions(session_type=SessionType.AGENT)
print(f"Total sessions in Valkey: {len(all_sessions)}")

if all_sessions:
    print("\nSession details:")
    session = all_sessions[0]
    print(f"The stored session: {session}")

```

## Params

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