Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Build Your First AI Agent in Python: Local, No API Key

Build Your First AI Agent in Python: Local, No API Key

One tool-using agent in plain Python with Ollama and qwen2.5:3b: tools, the loop, a stop rule, and a test that scores it
Created byAdi Tejus
Last updated 12/2026
English
English

What you'll learn

  • Explain what an AI agent is: a model, tools and a loop, and why a plain model call is not one
  • Run a free local model (qwen2.5:3b) with Ollama and call it from Python with no API key
  • Describe a Python function as a tool and read the tool call the model sends back
  • Write the agent loop that runs tools and feeds results back until the model answers
  • Add a second tool and watch the model choose and combine the right tools
  • Add stop rules so the agent gives up cleanly instead of looping or guessing
  • Score your agent with a 10-question test checked by code
  • Spot the real failures of small models and fix the ones that code can catch

Course content

5 sections • 10 lectures • 47m total length
  • Your first AI agent: two tools, one loop, a free model3:17

    A real run: the agent checks a 120 EUR hotel night against a made-up company policy with two tools and answers VERDICT: WITHIN. What an agent is (a model, tools, a loop), the expense-check job used through the course, and the plan. Every run was recorded for real on 28 November 2026.

  • Set up Ollama and make your first model call4:18

    Install Ollama and qwen2.5:3b (1.9 GB, no GPU, no key), run the 18 offline tests, read the 46-line client, and see what a plain model call does with a question about your company (the real answer is in the video). Includes the error you get when Ollama is not running, and the fix.

Requirements

  • Basic Python: you can run a script and read a function
  • A computer with about 4 GB of free memory and 3 GB of disk for the model (no GPU needed)
  • No API key, no paid account: everything runs locally

Description

This course contains the use of artificial intelligence.

Build one real, tool-using AI agent in plain Python, run it on a free local model, and test it with code. No API key, no paid account, no GPU, no framework.

The job is one you would see at work: an expense assistant that checks a claim against a company policy, such as "A hotel night cost 120 EUR. Is that within policy?". The agent asks for tools, our code runs them, and the loop continues until it can answer WITHIN, OVER or UNKNOWN.

What you build, step by step

  • A plain model call with Ollama and qwen2.5:3b, and why it cannot answer questions about your company

  • One tool: a Python function plus a description, and the exact tool call the model sends back

  • The agent loop: run the tool, send the result back, repeat until the model answers

  • A second tool, and how the model chooses and combines tools

  • Stop rules: an answer, the same call twice, a step budget, and a clean give-up instead of a guess

  • A 10-question test scored by code, and the details of every failure

  • What breaks, and fixes you can trust because code makes the decisions

Real runs, honest numbers. Everything you see was recorded on 28 November 2026 on a 2-core cloud machine with no GPU. The first version of the agent used the right tools in 10 of 10 test questions and still got only 5 of 10 verdicts right. After the fixes in lessons 8 and 9, the same free model scored 14 of 14 on our test questions and 4 of 4 on four holdout questions written after the fix was frozen (a small sample). The course shows the failures as well as the fixes, because that is how you learn to build agents that work.

Real AI, tested for real: every result is measured, nothing is made up.

Who this is for: Python beginners and developers who want to understand how an AI agent really works by building and testing a small one, before moving on to frameworks and production tools. You need basic Python and a computer with about 4 GB of free memory.

The course files (standard-library Python plus offline tests) are shown in every lesson. The policy, the exchange rates and every claim are made up for the course.

Ollama, Qwen and Alibaba Cloud are trademarks of their owners; this course is not affiliated with or endorsed by them.

Who this course is for:

  • Python beginners who want to build their first AI agent and see how it really works
  • Developers who used ChatGPT-style chat but never wired a model to their own code
  • Students and professionals who want a free, local starting point before bigger agent courses