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

# Server-side example for the learnings REST endpoints

> This sets up an AgentOS instance with a learning-enabled agent so that you can exercise the /learnings CRUD endpoints from a client (see rest_api_learnings.py).

```python learnings_with_agentos.py theme={null}
"""Server-side example for the learnings REST endpoints.

This sets up an AgentOS instance with a learning-enabled agent so that you can
exercise the /learnings CRUD endpoints from a client (see rest_api_learnings.py).

Run with:
    .venvs/demo/bin/python cookbook/05_agent_os/learnings/learnings_with_agentos.py

Then in another terminal, run rest_api_learnings.py to hit the endpoints.
"""

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

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

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

assistant = Agent(
    name="Assistant",
    model=OpenAIResponses(id="gpt-5.4"),
    instructions=["You are a helpful assistant. Use what you know about the user."],
    db=db,
    learning=learning,
)

agent_os = AgentOS(
    description="AgentOS exposing the /learnings CRUD endpoints",
    agents=[assistant],
)
app = agent_os.get_app()


if __name__ == "__main__":
    """Run the AgentOS.

    The learnings endpoints will be available at:
      GET    /learnings
      POST   /learnings
      GET    /learnings/{learning_id}
      PATCH  /learnings/{learning_id}
      DELETE /learnings/{learning_id}

    See http://localhost:7777/docs for interactive OpenAPI docs.
    """
    agent_os.serve(app="learnings_with_agentos:app", reload=True)
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[os]" fastmcp openai starlette
    ```
  </Step>

  <Step title="Export your API keys">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export JWT_VERIFICATION_KEY="your_jwt_verification_key_here"
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:JWT_VERIFICATION_KEY="your_jwt_verification_key_here"
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `learnings_with_agentos.py`, then run:

    ```bash theme={null}
    python learnings_with_agentos.py
    ```
  </Step>
</Steps>

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