Agent with Storage
Code
1from kern.agent import Agent2from kern.models.litellm import LiteLLM3from kern.db.sqlite import SqliteDb4from kern.tools.hackernews import HackerNewsTools56# Setup the database7db = SqliteDb(8 db_file="tmp/data.db",9)1011# Add storage to the Agent12agent = Agent(13 model=LiteLLM(id="gpt-5-mini"),14 db=db,15 tools=[HackerNewsTools()],16 add_history_to_context=True,17)1819agent.print_response("How many people live in Canada?")20agent.print_response("What is their national anthem called?")Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export LITELLM_API_KEY=xxxInstall dependencies
1uv pip install -U litellm openai kern-aiRun Agent
1python cookbook/11_models/litellm/db.py