Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Claude Agent SDK & FastAPI: Production AI Agents 2026
New
24 students

Claude Agent SDK & FastAPI: Production AI Agents 2026

Build a real support agent in Python: your own tools, FastAPI, streaming, auth, budgets, evals, Docker and Cloud Run
Created byJosé Calderón
Last updated 9/2026
English
English

What you'll learn

  • Run the Claude Agent SDK from Python, set the options that matter, keep sessions, and know what each run costs
  • Give an agent exactly the tools it needs, write your own in-process tools, and gate every change in code
  • Defend an agent against prompt injection that arrives through tool results, and prove it with tests
  • Put the agent behind FastAPI with streaming, one session per user, structured answers, memory and subagents
  • Deploy it with Docker and Cloud Run, with the API key in a secret and a user without privileges
  • Add authentication, per-user daily budgets, rate limits, timeouts and clean handling of model failures
  • Make it observable with structured logs, and gate changes with an eval suite wired into CI
  • Run agent jobs on a schedule that alerts you when they do not run, and compare the SDK with Claude Managed Agents

Course content

5 sections • 31 lectures • 1h 20m total length
  • Welcome: what you will build and how this course works3:31

    What this course is and how it is taught: one agent, Deskmate, built with the Claude Agent SDK and Python, from a first script to a cloud deployment with its own tools, users, budgets and tests. Every demo is a real run with its real cost on screen, including the runs that go wrong. You also see the route through the five sections, what you need, and what each download contains.

  • Four ways to run Claude, and when each one fits3:07

    The Messages API, Claude Code, the Agent SDK and Managed Agents are the same model with different machinery around it. One question asked three ways, with the tokens and cost of each, and the reasons this course builds on the SDK.

    Download: the project with the script that runs the same question through all three.

  • Install, and the first query(): the message stream3:13

    Install the SDK with uv, run the first query, and read every message that comes back: the init message, the assistant's answer, and the result with turns, tokens and cost. With no tools, the agent invents a feature that does not exist, and you will see exactly why.

    Download: the Deskmate starting point and the first script.

  • The options that matter3:39

    What the default options really do, and what each line changes: the model, the system prompt, tools versus allowed tools, settings sources, the working folder and the five permission modes. Six real runs, from twenty cents for a single word down to a twentieth of a cent.

    Download: the project with the options script, one experiment per argument.

  • Sessions: resume, fork, and where it all lives3:10

    Why a new process forgets, how resume brings the conversation back, and how fork branches it without touching the original. Then where every session is written on disk, what is inside, and the option that moves sessions into your own storage for servers.

    Download: the project with the sessions script.

  • The bill: tokens, turns, and two fuses4:07

    Where the numbers of a run live, the small extra call you did not make, how prompt caching works and when it cannot help, and what the turn and budget caps really do when they fire, including the exception that follows the result.

    Download: the project with the bill script, one experiment per argument.

  • Quiz 1: The SDK, and what it is not

Requirements

  • Comfortable with Python (functions, async/await helps) and the command line
  • Python 3.12 or later and uv on Windows, macOS or Linux
  • Claude Code installed: the SDK runs its command-line tool under the hood
  • An Anthropic API key with a few dollars of credit (the runs in the course cost cents each)
  • Optional: Docker, a Google Cloud account for the Cloud Run lessons, and a GitHub account for CI and scheduled runs

Description

This course contains the use of artificial intelligence.

An agent that answers a question in a notebook is easy. An agent that real people call over HTTP, that spends money on every request, that reads data other people wrote, and that has to be right more often than not, is a different job. This course is about that job.

You build one project from start to finish: Deskmate, a support agent for a small product team. It starts as a knowledge base and six tickets, and ends as a service with its own tools, a web page, sessions and memory, users with budgets, rate limits, logs you can query, an eval suite in CI, a security check that runs on every start, and a morning digest on a schedule. It runs in a container on Cloud Run.

Every number in the course is real. Every run on screen was actually executed with the Claude Agent SDK and checked. When something failed, you see the failure and the fix: the budget fuse that returned an error after the result, the three-second timeout that took eight, the eval that passed a change that invented a feature, the scheduled job that never ran.

What you'll practice:

  • The SDK itself: query(), the options that matter, sessions, and what every run costs

  • Your own tools in the same process, a gate in code on anything that changes data, and hooks

  • External MCP servers, and prompt injection through tool results, measured and blocked

  • FastAPI around the agent: one endpoint, streaming with server-sent events, one session per user

  • Structured output with Pydantic, memory that survives, subagents, and a minimal web page

  • Docker and Cloud Run with the key in a secret, never in the image

  • Tokens and daily budgets per user, rate limits, timeouts, and model failures as proper HTTP errors

  • Structured logs and traces that answer the questions you ask when something goes wrong

  • Evals that can say no, wired into CI, and a security review written as code

  • One new capability end to end, a scheduled job that tells you when it did not run, and the same job on Claude Managed Agents, compared on time, cost and trade-offs

Thirty lessons and twenty-nine downloads: each one is the project at that exact point, with its tests and the scripts used on screen, so you can run the same commands yourself.

How this course is made: the instructor designs and reviews the course. Every agent run shown was actually executed and checked, and the terminal output on screen comes from those runs. The narration uses an AI voice, the slide illustrations are AI-generated, and the instructor greeting that opens the first lesson is an AI avatar created from the instructor's own photo.

Who it's for: Python developers who want to put a Claude agent in front of real users, and teams deciding between building on the Agent SDK and using a hosted agent runtime.

Who this course is for:

  • Python developers who want to ship a Claude agent to real users, not just run a demo
  • Backend engineers who already use FastAPI and want to add an agent the right way
  • Teams choosing between the Claude Agent SDK and a hosted agent runtime, with measurements to decide