Anthropic Agent SDK - Quick Getting Started - Python
A quick start tutorial project demonstrating how to use the Anthropic Claude Agent SDK to build interactive AI agents with custom tools and conversational interfaces.
Project Files
main.py- Main entry point that loads environment variables and runs the agent with toolsbasic_query.py- Simple examples for making basic queries to the Claude APIagent_with_tools.py- Interactive chat loop with custom tools (calculator) and MCP server integrationinteractive_terminal.py- Two chat loop implementations:start_chat_loop()- Chat without historystart_chat_loop_continuous()- Chat with conversation history
.env.local- Local environment variables (not tracked in git).env.example- Template for environment variables
Setup Guide
1. Create Virtual Environment
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activate
2. Install Dependencies
pip install claude-agent-sdk python-dotenv numexpr anyio
3. Get Your API Key
- Visit Anthropic Console
- Sign up or log in to your account
- Navigate to API Keys section
- Create a new API key
4. Configure Environment
Copy the example environment file:
# Windows
copy .env.example .env.local
# macOS/Linux
cp .env.example .env.local
Edit .env.local and add your API key:
ANTHROPIC_API_KEY=your_actual_api_key_here