A hands-on demonstration suite for key Claude API capabilities, implemented as Jupyter notebooks. Each notebook is self-contained and focuses on a single feature.
| Notebook | Feature | Description |
|---|---|---|
001_thinking_complete.ipynb |
Extended Thinking | Surface Claude's internal reasoning before a final answer |
002_citations.ipynb |
Citations | Get source-attributed answers grounded in a document |
002_images.ipynb |
Vision / Image Analysis | Analyze satellite images for structured risk assessment |
002_pdfsupport.ipynb |
PDF Processing | Parse and summarize PDF documents directly |
003_caching.ipynb |
Prompt Caching + Tool Use | Cache large system prompts and tool definitions to cut costs |
005_code_execution.ipynb |
Code Execution + Files API | Execute Python in a sandbox, upload/download files |
- Python 3.9+
- Jupyter Lab or Jupyter Notebook
- An Anthropic API key
1. Clone the repository
git clone https://github.com/<your-username>/ClaudeFeatures.git
cd ClaudeFeatures2. Create and activate a virtual environment
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate3. Install dependencies
pip install anthropic python-dotenv jupyter4. Configure your API key
Copy the .env file template and add your key:
# .env
ANTHROPIC_API_KEY=your_api_key_hereNote:
.envis listed in.gitignoreand will never be committed.
5. Launch Jupyter
jupyter labEnables Claude's internal reasoning (ThinkingBlock) before it produces a final TextBlock answer. Useful for complex problems where showing work matters.
Key API parameters:
thinking={"type": "enabled", "budget_tokens": 10000}What to look for: The response object contains both a ThinkingBlock (redacted reasoning trace) and a TextBlock (final answer).
Passes an Earth article as a document and asks a factual question. Claude returns its answer with inline citations — each one carries the exact quoted text, document title, and character offsets.
Key API parameters:
{"type": "document", "source": {...}, "title": "...", "citations": {"enabled": True}}What to look for: CitationCharLocation objects in the response with cited_text, start_char_index, and end_char_index.
Sends a base64-encoded satellite image (images/prop7.png) to Claude with a structured fire risk assessment prompt. Claude identifies the residence, evaluates tree overhang and defensible space, and returns a 1–4 risk rating.
Key API parameters:
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "<base64>"}}What to look for: Structured property analysis in plain text with an explicit risk score.
Encodes earth.pdf as base64 and asks Claude to summarize it. Demonstrates that Claude can directly parse PDF content without a separate extraction step.
Key API parameters:
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "<base64>"}}What to look for: A one-sentence summary produced from the raw PDF bytes.
Wraps a large JavaScript-generation system prompt (~6k tokens) and four tool definitions with cache_control so they are reused across turns. Reduces cost significantly for multi-turn sessions with large, static context.
Key API parameters:
# On the last tool definition and on the system prompt block:
"cache_control": {"type": "ephemeral"}What to look for: usage.cache_creation_input_tokens on the first call, then usage.cache_read_input_tokens on subsequent calls — the second request costs far fewer tokens.
Tools defined:
add_duration_to_datetime— date/time arithmeticset_reminder— schedule a notificationget_current_datetime— current timestampdb_query— SQLite query execution
Uploads streaming.csv (a customer churn dataset) via the Files API, asks Claude to analyze it and generate a visualization, then downloads the resulting chart and report.
Beta headers required:
"anthropic-beta": "code-execution-2025-08-25, files-api-2025-04-14"Workflow:
- Upload CSV → get a
file_id - Pass
file_idin the message with acode_execution_20250825tool - Claude writes and runs Python in a sandboxed environment
- Download the output chart (
churn_analysis_dashboard.png) and report viafile_id
What to look for: The notebook demonstrates the full lifecycle — upload, execute, retrieve — and shows how each code execution block starts with a clean state (no persistent variables between blocks).
ClaudeFeatures/
├── .env # API key (not committed)
├── .gitignore
├── LICENSE # MIT
├── README.md
├── 001_thinking_complete.ipynb
├── 002_citations.ipynb
├── 002_images.ipynb
├── 002_pdfsupport.ipynb
├── 003_caching.ipynb
├── 005_code_execution.ipynb
├── earth.pdf # Sample document (citations + PDF demos)
├── streaming.csv # Sample churn dataset (code execution demo)
├── churn_analysis_dashboard.png # Output chart from code execution demo
└── images/
├── prop1.png
├── ...
└── prop7.png # Satellite images (vision demo)
All notebooks follow the same structure:
from dotenv import load_dotenv
import anthropic, os
load_dotenv()
client = anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
messages = []
def add_user_message(content):
messages.append({"role": "user", "content": content})
def chat(**kwargs):
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=8096,
messages=messages,
**kwargs
)
messages.append({"role": "assistant", "content": response.content})
return responseFeature-specific parameters (thinking, tools, caching headers) are passed as keyword arguments to chat().
MIT © 2026 Narmada Nannaka