In-Memory Storage

Use in-memory storage for testing and development.

InMemoryDb stores sessions, memories, metrics, evaluation runs, and knowledge in the current Python process.

Data is lost when the process exits. Use InMemoryDb for demos and tests. Use a persistent database for production and for features that InMemoryDb does not implement, including tracing, spans, and learning storage.

Usage

Start in a virtual environment and set the model key before running the example.

Set OpenAI Key

Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.

export OPENAI_API_KEY=sk-***

Install the openai package:

uv pip install agno openai
from agno.agent import Agent
from agno.db.in_memory import InMemoryDb

db = InMemoryDb()

agent = Agent(db=db)