
Claude Cookbooks
Official Claude API notebooks and code recipes for Python developers
Replaces —

Who it's for
The tool use and integration notebooks show how to wire Claude as a function-calling layer in an existing Python service: defining tools, handling responses, and managing multi-step execution loops. A developer familiar with REST APIs can work through the pattern in a few hours.
Your application stack is TypeScript, Go, or another non-Python language. The notebooks require manual translation and no equivalent notebooks cover those languages.
The RAG notebooks cover core retrieval patterns with Pinecone and Wikipedia as concrete backends, including chunking, retrieval, and prompt assembly. Teams can validate whether Claude handles their retrieval task well before investing in production infrastructure.
Your retrieval architecture is already running in production. The notebooks are starting points, not production-ready services with observability or error handling.
The cost optimization notebook measures an agent's per-task cost and pass rate across model configurations, then identifies the Pareto-optimal setup. Teams comparing Claude to other LLM APIs can use this notebook to measure their specific workload before committing to a provider.
You need benchmarks against real production traffic volumes at scale. The notebook measures cost at the task level; production traffic analysis requires the live API with actual request distributions.
The Cookbooks are structured as standalone notebooks, each covering one pattern from scratch. A developer new to the Claude API can start with classification or summarization and work toward more complex patterns like multi-step tool use, vision, or automated evaluations.
You need advanced multi-agent orchestration or production infrastructure patterns. The Cookbooks cover standard API patterns, not novel agent architectures or production-grade infrastructure.
The problem
Building real applications with an LLM API requires more than reading documentation. The documentation explains authentication, method signatures, and rate limits. It does not show how to chunk a large PDF for reliable context, handle tool use calls from a multi-step agent, get consistent JSON output from a conversational model, or tune cost versus quality across an agent pipeline. Most developers solve this by piecing together Stack Overflow answers, third-party blog posts, and trial-and-error. Paid AI development courses cover the concepts but rarely include copy-paste code built for the exact API version developers are using. The result is days of debugging integration code before getting to the actual product.
How it works
Three retrieval augmented generation notebooks cover the core patterns: supplementing Claude's responses with vector database lookups (Pinecone), Wikipedia search, and arbitrary web pages. Each notebook shows the retrieval, chunking, and prompt assembly steps as runnable Python.
Notebooks cover wiring Claude to external tools and functions, including a customer service agent, a calculator, and SQL query generation. Each notebook shows how to define tools, pass them to the API, and handle multi-step execution loops in Python.
A dedicated multimodal section covers getting started with images, best practices for vision tasks, interpreting charts and PowerPoint slides, and transcribing text from forms. Each notebook uses Claude's vision input directly, with no additional vision service required.
A cost optimization notebook walks through measuring an agent's pass rate and cost per task, then finding the Pareto-optimal model configuration. A separate prompt caching notebook covers techniques for reducing token spend on repeated context.
Two notebooks address output reliability: one on using Claude to score and evaluate prompt outputs automatically, and one on ensuring consistent JSON structure from any Claude model. Both patterns are prerequisites for production deployments that depend on predictable output.
A sub-agents notebook demonstrates how to use Claude Haiku as a sub-agent in combination with Claude Opus, showing the pattern for multi-model orchestration where different models handle different roles in a pipeline.
Features
- RAG pipeline notebooks with Pinecone and Wikipedia
- Tool use and external function integration
- Multimodal vision notebooks
- Cost optimization and prompt caching
- Automated evaluations and reliable JSON output
- Sub-agent orchestration with Haiku and Opus
How to install
Install the notebooks locally by cloning the repository and setting up the Python environment.
git clone https://github.com/anthropics/claude-cookbooks
pip install anthropic jupyterRecommended for this setup
Strengths
- Written and maintained by Anthropic's own team: Every notebook is maintained by Anthropic, the team that builds Claude. The code patterns reflect current API conventions and are updated alongside the model. Third-party tutorials often lag behind API changes or use deprecated parameters; the Cookbooks are the canonical reference for Claude-specific patterns.
- MIT license with no commercial restrictions: The MIT license means any notebook can be copied, adapted, and shipped into a production product without attribution requirements or commercial restrictions. Unlike proprietary examples tied to enterprise platform subscriptions, these have no licensing friction for teams building commercial products.
- Actively maintained since August 2023: The repository launched in August 2023 and was last updated on October 29, 2026, with active development from the API creators throughout. This maintenance record means the notebooks reflect the current API surface rather than a snapshot of older method signatures.
- Covers the full Claude API capability surface: The collection spans classification, retrieval augmented generation, summarization, tool use, integrations (Pinecone, Wikipedia, web pages), multimodal vision, PDF handling, sub-agents, automated evaluations, JSON mode, content moderation, prompt caching, and cost optimization. A developer exploring any major Claude capability can find a starting notebook.
Trade-offs
- All notebooks require an Anthropic API key: Running the notebooks requires an Anthropic API key. Anthropic offers a free tier for development, but production-scale usage is billed by token. The notebooks are not usable offline or with local LLM models; they are tied to the Anthropic API, so developers must account for API spend during experimentation.
- Python-centric examples require manual translation for other languages: The README notes that examples are primarily written in Python and that concepts can be adapted to any language. JavaScript, TypeScript, and Go developers must translate the Python patterns manually; no equivalent notebooks for other languages are included in the repository.
- 90 open issues; gaps in some advanced API features: With 90 open issues as of October 2026, the repository has active requests for patterns not yet covered. Some advanced agent architectures, streaming patterns, and newer API features may not have a dedicated notebook, requiring developers to adapt from the closest existing example.
Tech stack
FAQ
The Cookbooks themselves are MIT licensed and free to use, copy, and modify. Running the notebooks requires an Anthropic API key; Anthropic offers a free tier for development, and production usage is billed by token. The notebooks work with any Claude model your API key can access.
The examples are primarily Python, using Jupyter notebooks. The README notes that concepts can be adapted to any language that supports the Claude API. Anthropic does not currently include TypeScript or Go equivalents in the same repository; developers on those stacks must adapt the Python patterns manually.
No dedicated infrastructure is required. The notebooks run in any Jupyter environment: locally, on Google Colab, or on a self-hosted JupyterHub instance. The main dependency is the `anthropic` Python package alongside standard libraries such as `jupyter`.
The repository was last updated on October 29, 2026 and has been actively maintained since its August 2023 launch. Anthropic maintains the repository directly, so examples typically reflect current API conventions. Older notebooks may use earlier method signatures; check individual notebook dates when working with newer API features.
The official Claude documentation covers API reference, method signatures, and conceptual guides. Claude Cookbooks is the practical complement: runnable Python notebooks demonstrating complete patterns such as RAG pipelines, tool use agents, multimodal vision, and automated evaluations. The documentation explains what the API does; the Cookbooks show how to use it end to end.