Build an AI Agent From Scratch in Python - Tutorial for Beginners

Tech With Tim March 14, 2025
Video Thumbnail
Tech With Tim Logo

Tech With Tim

@techwithtim

About

I'm Tim, a self-taught developer & entrepreneur who brings you educational tech content without the fluff and noise. I went from a broke dropout working at McDonalds to making $100k+/month as a developer, travelling the world and moving to Dubai all before the age of 22. I've since helped thousands of aspiring developers land their first software engineering role and assisted mid-level devs land jobs at companies like google.

Video Description

Thanks to Microsoft for sponsoring this video! Submit your #CodingWithCopilot story for a chance to be featured in an upcoming video! In this video, you'll learn how to build an AI agent from scratch in Python. I'll walk you through everything step-by-step. This will be very beginner friendly, and you'll learn how to make something quite interesting in Python with some popular frameworks like LangChain. I'll show you how to use various LLMs like Claude or GPT, how you can give the agent access to various tools, and how you can structure the output of the agent so you can use it in your code. 🎞 Video Resources 🎞 Code in this video: https://github.com/techwithtim/PythonAIAgentFromScratch Learn Python Virtual Environments: https://www.youtube.com/watch?v=Y21OR1OPC9A Get Your Anthropic API Key: https://console.anthropic.com/settings/keys Get Your OpenAI API Key: https://platform.openai.com/api-keys ⏳ Timestamps ⏳ 00:00 | Overview 00:35 | Agent Demo 01:38 | Setup/Requirements 06:53 | Basic Code Setup/Imports 08:37 | Using Claude or GPT 10:00 | Getting Your API Key 11:32 | Basic LLM Functionality 12:43 | Structured Output/Models 15:42 | Prompt Templates 17:33 | Creating & Running the Agent 21:00 | Output Parsing 23:39 | Adding Prebuilt Tools 30:48 | Custom Tool Calling Hashtags #CodingWithCopilot #Sponsored

Python AI Project Essentials

AI-recommended products based on this video

Loading...
10.1 Inch Touch Portable Monitor IPS Screen 1366x768P 60Hz 400 Brightness 99% sRGB HDMI USB-C Monitors Switch for Xbox PS3/4/5 Laptop Compatible with Raspberry Pi, Mini Touch Screen

10.1 Inch Touch Portable Monitor IPS Screen 1366x768P 60Hz 400 Brightness 99% sRGB HDMI USB-C Monitors Switch for Xbox PS3/4/5 Laptop Compatible with Raspberry Pi, Mini Touch Screen

(1)
$99.99
FREE delivery Mon, Aug 11
Loading...
ELECROW 8 Inch Portable Monitor, 1280x800 Mini HD Display with Built-in Speakers, USB Powered, Non-Touch LCD Screen for Raspberry Pi, PC, Laptop, Jetson Nano, Game Consoles

ELECROW 8 Inch Portable Monitor, 1280x800 Mini HD Display with Built-in Speakers, USB Powered, Non-Touch LCD Screen for Raspberry Pi, PC, Laptop, Jetson Nano, Game Consoles

(49)
$117.29$102.21
$6.86 delivery Thu, Aug 14
Loading...
7 Inch Portable Monitor Touchscreen HD 1024x600 LED Display Dual HDMI Port Small Monitor for PC Raspberry Pi Laptop Computer Xbox PS4/5 Switch Built-in Speakers

7 Inch Portable Monitor Touchscreen HD 1024x600 LED Display Dual HDMI Port Small Monitor for PC Raspberry Pi Laptop Computer Xbox PS4/5 Switch Built-in Speakers

(61)
$68.99
FREE delivery Tue, Aug 12
Loading...
BrosTrend 1800Mbps WiFi 6 Linux WiFi Adapter for PC and Raspberry Pi 2+, Long Range USB WiFi Dongle Linux for Ubuntu, Mint, Debian, Kubuntu, Lubuntu, Zorin, Windows 11/10, Dual Band Wireless Antenna

BrosTrend 1800Mbps WiFi 6 Linux WiFi Adapter for PC and Raspberry Pi 2+, Long Range USB WiFi Dongle Linux for Ubuntu, Mint, Debian, Kubuntu, Lubuntu, Zorin, Windows 11/10, Dual Band Wireless Antenna

(288)
$54.14
FREE delivery Sun, Jun 22
Loading...
TRAUSI 1080P HD Webcam with Microphone, Noise Cancellation, Privacy Cover, Wide-Angle Lens, Auto Light Correction, Plug & Play USB Webcam for Laptop, Desktop, PC, Mac, Zoom, Skype, Streaming Black

TRAUSI 1080P HD Webcam with Microphone, Noise Cancellation, Privacy Cover, Wide-Angle Lens, Auto Light Correction, Plug & Play USB Webcam for Laptop, Desktop, PC, Mac, Zoom, Skype, Streaming Black

(205)
$28.99
FREE delivery Wed, Jul 2 on your first order
1K+ bought in past month
Loading...
Shcngqio 1080P Full HD Webcam with Privacy Cover, Wide Angle Lens, Active Light Correction, Plug and Play USB Webcam for PC, Desktop,Laptop (Black)

Shcngqio 1080P Full HD Webcam with Privacy Cover, Wide Angle Lens, Active Light Correction, Plug and Play USB Webcam for PC, Desktop,Laptop (Black)

(205)
$28.99
Prime
500+ bought in past month
Loading...
TRAUSI HD Webcam with Microphone, Noise Cancellation, Privacy Cover, Wide-Angle Lens, Auto Light Correction, Plug & Play USB Webcam for Laptop, Desktop, PC, Mac, Zoom, Skype, Streaming (1080P, Black)

TRAUSI HD Webcam with Microphone, Noise Cancellation, Privacy Cover, Wide-Angle Lens, Auto Light Correction, Plug & Play USB Webcam for Laptop, Desktop, PC, Mac, Zoom, Skype, Streaming (1080P, Black)

(284)
$27.99
Prime
1K+ bought in past month
Loading...
Wireless Lavalier Microphone for iPhone/iPad/Android Phone, Utsund LED Display Mini Mic for Video Recording, USB C Microphone Clip on Lapel Mics for Podcast Interview Tiktok Vlog

Wireless Lavalier Microphone for iPhone/iPad/Android Phone, Utsund LED Display Mini Mic for Video Recording, USB C Microphone Clip on Lapel Mics for Podcast Interview Tiktok Vlog

(66)
$19.99
FREE delivery Sat, Jun 14 on your first order
200+ bought in past month
Loading...
Wireless Lavailer Microphone for iPhone, Android, Camera, iPad, USB C, 4 in 1 Professional Mini Microphone with Noise Reduction, Wireless Mic for Video Recording, Vlog, YouTube, TikTok

Wireless Lavailer Microphone for iPhone, Android, Camera, iPad, USB C, 4 in 1 Professional Mini Microphone with Noise Reduction, Wireless Mic for Video Recording, Vlog, YouTube, TikTok

(329)
$22.99
FREE delivery Sat, Jun 14 on your first order
300+ bought in past month
Loading...
USB C Headphones for iPhone 17/16/16e/15 Pro Max/Plus, Type C Earbuds Wired Earphones (Microphone & Remote Control) Noise Cancelling for lPad Pro, Galaxy S23/S22/S21/S20

USB C Headphones for iPhone 17/16/16e/15 Pro Max/Plus, Type C Earbuds Wired Earphones (Microphone & Remote Control) Noise Cancelling for lPad Pro, Galaxy S23/S22/S21/S20

(30)
$12.59
FREE delivery Tue, Mar 24 on your first order
500+ bought in past month
Loading...
USB C Headphones for iPhone 17/16/16e/15 Pro Max/Plus, Type C Earbuds Wired Earphones (Microphone & Remote Control) Noise Cancelling for lPad Pro, Galaxy S23/S22/S21/S20/Ultra Note10/20, Pixel

USB C Headphones for iPhone 17/16/16e/15 Pro Max/Plus, Type C Earbuds Wired Earphones (Microphone & Remote Control) Noise Cancelling for lPad Pro, Galaxy S23/S22/S21/S20/Ultra Note10/20, Pixel

(23)
$12.59
FREE delivery Fri, Feb 13 on your first order
Loading...
Spigen Case for Galaxy S25 Case, Tough Armor (Ai) MagFit [Wireless Charging] Compatible with MagSafe - Black

Spigen Case for Galaxy S25 Case, Tough Armor (Ai) MagFit [Wireless Charging] Compatible with MagSafe - Black

(2,126)
$28.99
FREE delivery Sat, Jun 14 on your first order
500+ bought in past month
Loading...
Spigen Case for iPhone 16 Plus Case, Tough Armor (AI) [MagFit] Compatible with MagSafe - Black

Spigen Case for iPhone 16 Plus Case, Tough Armor (AI) [MagFit] Compatible with MagSafe - Black

(818)
$29.99
FREE delivery Sat, Jun 14 on your first order
Loading...
Real-Time AI Translation Earbuds - 198 Languages 3-in-1 Translating Device, Écouteurs traducteurs Anglais-français, Clear Voice Translation Headphones with Charging Case for Travel & Learning Global Recycled Standard

Real-Time AI Translation Earbuds - 198 Languages 3-in-1 Translating Device, Écouteurs traducteurs Anglais-français, Clear Voice Translation Headphones with Charging Case for Travel & Learning Global Recycled Standard

(78)
$99.99
FREE delivery Thu, Apr 9
100+ bought in past month
Loading...
Real-Time AI Translation Earbuds - 198 Languages 3-in-1 Translating Device,Écouteurs traducteurs Anglais-français, Clear Voice Translation with Charging Case for Travel & Learning Global Recycled Standard

Real-Time AI Translation Earbuds - 198 Languages 3-in-1 Translating Device,Écouteurs traducteurs Anglais-français, Clear Voice Translation with Charging Case for Travel & Learning Global Recycled Standard

(77)
$49.97
FREE delivery Fri, Feb 27