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

# Serve Agent Learning with AgentOS

> Serve a learning-enabled agent and the shared database that backs both its automatic user learning and the AgentOS /learnings CRUD routes.

```python learnings_with_agentos.py theme={null}
"""
Serve Agent Learning with AgentOS
=================================

Serve a learning-enabled agent and the shared database that backs both its
automatic user learning and the AgentOS /learnings CRUD routes.

Prerequisites: OPENAI_API_KEY
Run: .venvs/demo/bin/python cookbook/05_agent_os/11_learnings/learnings_with_agentos.py
Try: Run rest_api_learnings.py from this folder in another terminal
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.learn import LearningMachine
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS

# ---------------------------------------------------------------------------
# Create Learning-Enabled AgentOS
# ---------------------------------------------------------------------------

db = SqliteDb(
    id="learnings-db",
    db_file="tmp/learnings.db",
)

learning = LearningMachine(
    db=db,
    model=OpenAIResponses(id="gpt-5.5"),
    user_profile=True,
    user_memory=True,
    namespace="global",
)

learning_assistant = Agent(
    id="learning-assistant",
    name="Learning Assistant",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    learning=learning,
    instructions=(
        "Be concise and helpful. Use persistent user details when they are "
        "relevant to the response."
    ),
)

agent_os = AgentOS(
    id="learnings-os",
    description="AgentOS exposing agent learning and learning CRUD routes.",
    db=db,
    agents=[learning_assistant],
)
app = agent_os.get_app()

# ---------------------------------------------------------------------------
# Run Learnings Server
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    agent_os.serve(app=app)
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U "agno[os]" openai
```

**2. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Run the example**

Save the code above as `learnings_with_agentos.py`, then run:

```bash theme={null}
python learnings_with_agentos.py
```

Full source: [cookbook/05\_agent\_os/11\_learnings/learnings\_with\_agentos.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/05_agent_os/11_learnings/learnings_with_agentos.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.