# Build Your First AI Agent in Python -- A Hands-On Guide to the Claude Agent SDK

DevFeed: [Build Your First AI Agent in Python -- A Hands-On Guide to the Claude Agent SDK](<https://devfeed.tech/articles/build-your-first-ai-agent-in-python-a-hands-on-guide-to-the-claude-agent-sdk-22851.md>)

Original publisher: [Read original article](<https://medium.com/google-developer-experts/build-your-first-ai-agent-in-python-a-hands-on-guide-to-the-claude-agent-sdk-cb5ba3239dcf?source=rss----a67bd6fa7d58---4>)

Author: Geeta Kakrani

Published: 2026-08-21T09:14:00Z

Content type: tutorial

Language: en

Sources: [Google Developer Experts - Medium](<https://devfeed.tech/sources/google-developer-experts-medium.md>)

Topics: [SDKs](<https://devfeed.tech/topics/sdks.md>), [Claude](<https://devfeed.tech/topics/claude.md>), [Python](<https://devfeed.tech/topics/python.md>), [AI Agent](<https://devfeed.tech/topics/ai-agent.md>), [anthropic](<https://devfeed.tech/topics/anthropic.md>), [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [API keys](<https://devfeed.tech/topics/api-keys.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>)

Tags: [agentic-ai](<https://devfeed.tech/tags/agentic-ai.md>), [ai](<https://devfeed.tech/tags/ai.md>), [ai-agent](<https://devfeed.tech/tags/ai-agent.md>), [anthropic](<https://devfeed.tech/tags/anthropic.md>), [anthropic-claude](<https://devfeed.tech/tags/anthropic-claude.md>), [api](<https://devfeed.tech/tags/api.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [claude](<https://devfeed.tech/tags/claude.md>), [claude-code](<https://devfeed.tech/tags/claude-code.md>), [guide](<https://devfeed.tech/tags/guide.md>), [python](<https://devfeed.tech/tags/python.md>), [sdk](<https://devfeed.tech/tags/sdk.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

This step-by-step tutorial explains how to build an AI agent in Python with Anthropic's Claude Agent SDK. It covers project setup, SDK installation, API-key configuration, and the SDK's agent loop, tools, MCP servers, and subagents.

## Source excerpt

A step-by-step, no-hype tutorial using Anthropic's official Agent SDK By Geeta Kakrani -- AI Consultant | Google Developer Expert (AI) If you've been writing simple "call the API, get a response" scripts with an LLM, you already know the limitation: every call is a one-shot Q&A. You ask, it answers, the conversation is over. There's no planning, no tool use, no "keep working until the task is actually done." The Claude Agent SDK -- Anthropic's official, open-source Python and TypeScript library -- solves exactly this. It gives you the same agent loop, tool execution engine, and context management that powers Claude Code, but as a library you can call from your own Python program. No need to build your own tool-calling loop from scratch. In this tutorial, we'll install it, set it up, and build a working agent -- step by step, using only what's documented and verified. What you'll need Python 3.10 or later An Anthropic API key (from the Claude Console) 15-20 minutes Step 1: Set up your project Create a fresh folder for this project. The SDK, by default, has access to files in this folder and its subfolders -- so keep it clean and dedicated. bash mkdir my-agent && cd my-agent python3 -m venv .venv source .venv/bin/activate # on Windows: .venv\Scripts\activateStep 2: Install the SDK bash pip install claude-agent-sdk That's it -- no separate CLI install needed. The package bundles the Claude Code CLI binary internally and uses it automatically. Note: If pip throws an externally-managed-environment error (common on newer Ubuntu/Debian/Homebrew Python), make sure you're inside the virtual environment you just activated in Step 1.Step 3: Set your API key Create a .env file in your project folder: ANTHROPIC_API_KEY=your-api-key-here (If you're on AWS, Google Cloud, or Azure, the SDK also supports Bedrock, Vertex AI, and Azure Foundry authentication -- but for this tutorial, a plain API key is simplest.) The architecture, before you write any code It helps to see the whole picture b