This repository contains hands-on exercises and examples from the Anthropic course: Building with the Claude API.
📁 001-Accessing-Claude_with-the-API/
Learn the fundamentals of interacting with Claude through the Anthropic API.
| Notebook | Description |
|---|---|
001_requests.ipynb |
Basic API requests, message handling, and multi-turn conversations |
001_requests_exercise.ipynb |
Build an interactive chatbot using the messages API |
002_system_prompt.ipynb |
Using system prompts to guide Claude's behavior |
002_system_prompt_exercise.ipynb |
Create a concise Python code assistant with system prompts |
003_temperature.ipynb |
Controlling output randomness with the temperature parameter |
004_streaming.ipynb |
Real-time response streaming and handling stream events |
005_controlling_output.ipynb |
Message prefilling, stop sequences, and structured output (JSON) |
Learn how to systematically evaluate and grade prompt outputs using datasets, model-based grading, and code-based validation.
| Notebook | Description |
|---|---|
001_generating_dataset.ipynb |
Generate evaluation datasets for testing prompts |
002_running_eval.ipynb |
Run evaluations across test cases and collect results |
003_model_based_grading.ipynb |
Use Claude to grade and evaluate AI-generated solutions |
004_code_based_grading.ipynb |
Combine syntax validation (JSON, Python, Regex) with model grading |
005_exercise.ipynb |
Exercise: Enhance the model grader with solution criteria |
Master essential prompt engineering techniques to improve Claude's output quality, consistency, and accuracy.
| Notebook | Description |
|---|---|
001_prompting.ipynb |
Introduction to prompt engineering with the PromptEvaluator framework |
002_being_clear_direct.ipynb |
Writing clear and direct prompts for better results |
003_being_specific.ipynb |
Using guidelines and step-by-step instructions for complex tasks |
004_xml.ipynb |
Structuring prompts with XML tags for clarity and organization |
005_providing_examples.ipynb |
One-shot and multi-shot examples to guide model behavior |
006_prompting_exercise.ipynb |
Exercise: Extract topics from scholarly articles |
Learn how to extend Claude's capabilities by defining tools, handling tool calls, and building multi-turn agentic workflows.
| Notebook | Description |
|---|---|
001_tools_function.ipynb |
Introduction to tool functions for accessing real-time information |
002_tools_schemas.ipynb |
Creating JSON schemas to define tool arguments |
003_tools_handling_message_blocks.ipynb |
Handling multi-block messages with text and tool use content |
004_tools_sending_tool_results.ipynb |
Executing functions and sending results back to Claude |
005_tools_multi-turn-conversations.ipynb |
Calling multiple tools in sequence to answer a single question |
006_tools_implementing_multiple_turns.ipynb |
Building a conversation loop that runs until tool use completes |
007_tools_using_multiple_tools.ipynb |
Integrating multiple tools into a single implementation |
008_tools_batch_tools.ipynb |
Running multiple tool calls in parallel within a single message |
009_tools_structured_data.ipynb |
Using tools to extract structured data reliably |
010_tools_fine_grained_tool_calling.ipynb |
Combining tool use with streaming for real-time updates |
011_tools_text_edit.ipynb |
Using Claude's built-in text editor tool for file operations |
012_tools_web_search.ipynb |
Enabling Claude's built-in web search tool for current information |
📁 005-Retrieval-Augmented-Generation/
Build RAG pipelines from scratch, covering chunking strategies, embeddings, vector search, lexical search, and advanced retrieval techniques.
Additional setup required for this module:
- Install the Voyage AI package:
pip install voyageai- Add your Voyage AI API key to
.env:VOYAGE_API_KEY="your_key_here"(Get one here)
| Notebook | Description |
|---|---|
001_introducing-RAG.ipynb |
Text chunking strategies: size-based, structure-based, and semantic-based |
002_embeddings.ipynb |
Generating text embeddings for semantic search over document chunks |
003_vectordb.ipynb |
Complete RAG flow with chunking, embeddings, vector storage, and similarity search |
004_bm25.ipynb |
BM25 lexical search as a complement to semantic search |
005_hybrid.ipynb |
Hybrid search combining semantic and lexical retrieval with Reciprocal Rank Fusion |
006_reranking.ipynb |
Reranking retrieved documents with Claude for improved accuracy |
007_contextual.ipynb |
Contextual retrieval to preserve document context in chunked passages |
Explore Claude's advanced built-in features including extended thinking, vision, PDF processing, citations, caching, and code execution.
| Notebook | Description |
|---|---|
001_thinking.ipynb |
Extended thinking for complex reasoning before generating responses |
002_images.ipynb |
Vision capabilities for analyzing and understanding images |
003_pdf.ipynb |
Reading and analyzing PDF files for document processing |
004_citations.ipynb |
Citations to trace answers back to specific source locations |
005_caching.ipynb |
Prompt caching to speed up responses and reduce costs |
006_code_execution.ipynb |
Files API and code execution for delegating complex tasks |
Learn how to build MCP servers and clients to extend Claude with tools, resources, and reusable prompts through a standardized protocol.
Additional setup required for this module:
- Install uv (recommended):
curl -LsSf https://astral.sh/uv/install.sh | sh- Run
uv syncinside thecli_projectdirectory to install dependencies- Add
CLAUDE_MODELto the project's.envfile (e.g.,CLAUDE_MODEL="claude-sonnet-4-5")
| File | Description |
|---|---|
NOTES.md |
Concise reference notes on MCP concepts and the sample project |
cli_project/mcp_server.py |
MCP server defining tools, resources, and prompts using FastMCP |
cli_project/mcp_client.py |
MCP client connecting to servers via stdio transport |
cli_project/main.py |
Entry point wiring the MCP client with an interactive CLI chat |
cli_project/core/chat.py |
Multi-turn tool execution loop with Claude |
cli_project/core/cli_chat.py |
CLI chat with @ document mentions and / command prompts |
cli_project/core/tools.py |
Tool discovery and execution across multiple MCP clients |
cli_project/core/cli.py |
Interactive CLI with tab-completion and auto-suggest |
Explore two powerful Anthropic applications — Claude Code and Computer Use — and build a real MCP document tools server using the included app_starter project.
Additional setup required for this module (
app_starter/):
- Install uv if not already installed:
curl -LsSf https://astral.sh/uv/install.sh | shcd 008-Anthropic-Apps/app_starteruv venv && source .venv/bin/activateuv pip install -e .- Run the MCP server:
uv run main.py- Run tests:
uv run pytest
| File | Description |
|---|---|
NOTES.md |
Notes on Claude Code, Computer Use, /init, and MCP server registration |
app_starter/main.py |
FastMCP server entry point registering document and math tools |
app_starter/tools/document.py |
Tool to convert PDF/DOCX files to Markdown via MarkItDown |
app_starter/tools/math.py |
Reference tool implementation demonstrating the expected tool definition pattern |
app_starter/tests/test_document.py |
pytest tests for the document conversion tool |
Learn the core strategies for building multi-step AI systems — chaining, routing, parallelization workflows — and fully autonomous agents powered by tools.
| File | Description |
|---|---|
NOTES.md |
Concise reference notes on workflows, agents, and when to use each strategy |
- Python 3.8+
- An Anthropic API key (Get one here)
-
Clone the repository:
git clone https://github.com/jaygaha/Building-with-the-Claude-API.git cd Building-with-the-Claude-API -
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure your API key:
cp .env-example .env
Then edit
.envand add your Anthropic API key. -
Launch Jupyter:
jupyter notebook