Build AI apps and agents with Python
Connect LLMs to your code, your data, and your tools
Real Python shows you how to call models like GPT and Claude from Python, ground their answers in your own documents with RAG, and build agents that use tools through MCP. Follow a guided path, practice with real code, and get help the moment you’re stuck.
from mcp.server.fastmcp import FastMCP mcp_server = FastMCP("Orders MCP server") @mcp_server.tool() def get_total_spent_by_customer(customer: str) -> int: """Get the total amount a customer has spent.""" ...
→ 160
- 40AI tutorials
- 15+video courses
- 35+interactive quizzes
- 25coding exercises
- 2guided learning paths
From your first API call to agents that use tools
You don’t need to train a model to build useful AI software. These are the skills that turn an LLM into a working Python application.
Call LLMs from Python
Send prompts to hosted models or run open models locally, and get structured, validated output back.
Ground answers in your data
Turn documents into embeddings, store them in a vector database, and retrieve the right context with RAG.
Build agents
Give models tools, memory, and state so they can plan, act, and work through multi-step tasks.
Connect tools with MCP
Write MCP servers that expose your data and functions to any LLM client, and test them from your terminal.
A clear path from API call to AI agent
Work through these stages in order. Together they make up the LLM Application Development With Python learning path, which mixes tutorials, video courses, quizzes, and exercises and tracks your progress as you go.
-
1
Connect to LLM APIs
Call hosted models like GPT and Claude, run open models on your own machine, and switch between providers with one API.
-
2
Craft prompts and use frameworks
Write prompts that get reliable results, then use LangChain to template prompts and chain model calls together.
-
3
Add retrieval-augmented generation
Convert documents into LLM-ready text, store embeddings in a vector database, and build a chatbot that answers from your own data.
-
4
Build AI agents
Create type-safe agents with structured output, then add state and control flow for multi-step workflows.
-
5
Connect agents to tools with MCP
Expose your data and functions through an MCP server, and build a client to test servers from your terminal.
-
Python Coding With AI
Put AI to work on your own code: choose an editor or terminal assistant like Cursor or Claude Code, brief it with context files, and review what it writes.
Want to understand how the models themselves work? Explore Machine Learning With Python. New to Python itself? Start with Python Basics first.
Give an LLM a tool it can call
This is a real exercise from the Connecting LLMs to Your Data With Python MCP Servers video course, and it’s the same tool from the example above. Write your function, register it on the server, and click Run Tests.
Running tests, hints, and solutions are included with a Real Python membership. Not a member yet? You can still read the task and write your solution before you join.
Read it, watch it, test it, practice it
Every AI topic comes in the formats that help it stick. Mix them however you like.
Tutorials
In-depth, example-driven guides to LLM APIs, RAG, agent frameworks, MCP, and AI coding tools.
Browse tutorials →Video courses
Follow along as an instructor builds a working AI project, one bite-sized lesson at a time.
Start with the OpenAI API →Quizzes
Check what you’ve learned in a few minutes and see exactly which concepts to review.
Take a quiz →Coding exercises
Build prompts, RAG pipelines, and MCP tools in your browser and get instant test feedback.
How exercises work →Agent not calling your tool? Ask right where you are
AI code fails in new ways: a tool the model never calls, a prompt that returns the wrong format, a retrieval step that pulls in the wrong documents.
Mentor AI sees the tutorial, lesson, or exercise you’re on and your code, and nudges you toward the fix one hint at a time, so you understand how the pieces fit together.
Meet Mentor AI →Your function logic sounds right. Writing the function is only half of it, though. How does mcp_server find out that this function exists?
@mcp_server.tool() above the function!Exactly. The decorator also passes your type hint and docstring to the LLM, so it knows when to call the tool. Now, what should happen for a customer like Tron who has no orders?
Learn the tools AI developers actually use
Model APIs, frameworks, vector databases, and protocols, each with a hands-on tutorial or course.
New and updated for 2026
AI tools change fast. The Real Python team keeps publishing and refreshing AI content, so what you learn matches the libraries and models you’ll use at work.
See all AI content →- CourseUsing the Claude API in Python
- TutorialAgentic Engineering in Python: From Vibes to Evidence
- CourseHow to Get Started With Ollama
- TutorialCrewAI in Python: Coordinating Teams of AI Agents
- TutorialLangGraph Tutorial: Build Stateful AI Agents in Python
- CourseTesting MCP Servers With a Python MCP Client
- QuizUsing the Claude API in Python
Questions and answers
Do I need to know Python before I start?
You should be comfortable with Python basics like functions, dictionaries, and installing packages. If you’re not there yet, the Python Basics learning path gets you ready.
Do I need a machine learning background?
No. Building AI apps is about calling existing models and wiring them into your code, not training models yourself. If you want to learn how models work under the hood, Machine Learning With Python covers that side.
Do I need paid API keys?
Not necessarily. Hosted APIs like OpenAI and Claude require an account, but you can also run open models on your own computer with Ollama and follow along without a paid key.
Which framework should I learn first?
Start by calling a model API directly so you understand what every framework does for you. Then pick up LangChain or LlamaIndex for RAG, and Pydantic AI or LangGraph for agents. The roadmap above follows that order.
Does this cover AI coding assistants too?
Yes. The Python Coding With AI learning path covers tools like Cursor, Claude Code, and GitHub Copilot, and how to brief and review the code they write.
What’s included in a membership?
Every Real Python membership includes all video courses, quizzes, coding exercises, and learning paths for AI and every other topic, along with Mentor AI as it rolls out.
Start building with AI
Get your free learning plan and follow the full AI roadmap, with courses, quizzes, coding exercises, and a mentor at your side.