learning-it by example

Back to the video

Local AI Agent in Python: No API Key (Ollama)

Build and run a tool-calling AI agent on your own laptop with Python and Ollama. No API key, no bill.

Video #01 ยท AI agents and MCP

Steps in the video

  1. 0:00 Run an AI agent locally
  2. 0:16 What an agent is
  3. 0:40 Setup with Ollama
  4. 1:02 Tools and the step limit
  5. 1:43 The agent loop
  6. 2:16 Running tools and handling errors
  7. 3:23 Running the agent
  8. 3:47 What just happened
  9. 4:10 What this does not show
  10. 4:47 Four mistakes to avoid
  11. 5:16 The silent wrong answer
  12. 5:51 Recap

Files

  • agent.py (47 lines)

Download the code (zip)

Tested with

Python 3.13.2 | ollama==0.6.3

What this does not show

One small local model (llama3.2), two toy tools and a single run: a demonstration, not a test. No permissions, logging or tool limits. The advice pages were read as search results; the output on screen is the evidence.

Sources

Learning IT by Example.