We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Build an AI Agent

Time for Boot.dev to cash in on the AI hype.

If you've ever used OpenCode, Cursor, or Claude Code as an "agentic" AI tool, you'll understand what we're building in this project.

We're building a toy version of Claude Code! We'll power it with free models from OpenRouter, accessed through the official OpenAI Python SDK. As long as you have an LLM at your disposal, it's actually surprisingly simple to build a (somewhat) effective custom agent.

OpenRouter gives us a single API (compatible with the OpenAI SDK) for hundreds of models, including a rotating set of free ones. We'll use the special openrouter/free model, which automatically routes each request to an available free model that supports the features we need (like tool calling).

The free tier is enough to finish this course, but it's rate-limited (roughly 50 requests per day). If you'd like a smoother experience, adding $10 of credit to your OpenRouter account (a one-time top-up) raises that limit to roughly 1,000 requests per day. Staying on the free tier costs nothing – the $10 is purely for convenience.

We'll keep updating this course as the situation with free tiers and model quality evolves!

for Windows Users

If you try to complete this course without WSL 2 installed on Windows, you're gonna have a bad time.

What Does the Agent Do?

The program we're building is a CLI tool that:

  1. Accepts a coding task (e.g., "strings aren't splitting in my app, pweeze fix πŸ₯ΊπŸ‘‰πŸ½πŸ‘ˆπŸ½")
  2. Chooses from a set of predefined functions to work on the task, for example:
    • Scan the files in a directory
    • Read a file's contents
    • Overwrite a file's contents
    • Execute the Python interpreter on a file
  3. Repeats step 2 until the task is complete (or it fails miserably, which is possible)

For example, I have a buggy calculator app, so I used my agent to fix the code:

> uv run main.py "fix my calculator app, it's not starting correctly"
# Calling function: get_files_info
# Calling function: get_file_content
# Calling function: write_file
# Calling function: run_python_file
# Calling function: write_file
# Calling function: run_python_file
# Final response:
# Great! The calculator app now seems to be working correctly. The output shows the expression and the result in a formatted way.

Prerequisites

  • Python 3.10+ installed (see the bookbot project for help if you don't already have it)
  • The uv project/package manager (installation docs)
  • Access to a Unix-like shell (e.g. zsh or bash)

Learning Goals

The learning goals of this project are as follows:

  1. Get an introduction to multi-directory Python projects.
  2. Understand how the AI tools that you'll almost certainly use on the job actually work under the hood.
  3. Practice your Python and functional programming skills.

The goal is not to build an LLM from scratch, but instead to use a pre-trained LLM to build an agent from scratch.

Assignment

To get started, make sure you have Python and the Boot.dev CLI installed and working.

OpenRouter is an external web service, and it may rate limit your project (especially on the free tier). On lessons like this one, failed submissions won't penalize you, so it's safe to retry if something goes wrong on the provider's end.

Not every lesson in this course is no-penalty, so read the instructions carefully and follow the submit flow each lesson asks for.

Submit the CLI tests.