PromptsMar 31, 2026·2 min read

Anthropic Cookbook — Official Claude Recipes

Official collection of notebooks and recipes for building with Claude. Prompt engineering, tool use, RAG, agents, multimodal, and enterprise patterns. By Anthropic. 37K+ stars.

TL;DR
Anthropic's official cookbook provides self-contained Jupyter notebooks covering prompt engineering, tool use, RAG, and agent patterns.
§01

What it is

The Anthropic Cookbook is the official repository of notebooks and code recipes for building applications with Claude. Each recipe is a self-contained Jupyter notebook that demonstrates a specific pattern: prompt engineering, tool use, retrieval-augmented generation, multi-step agents, multimodal inputs, and enterprise integration patterns.

The cookbook targets developers who are building production applications with the Claude API. It is maintained by Anthropic and reflects current best practices for the Claude model family.

§02

How it saves time or tokens

Instead of piecing together techniques from blog posts and forum threads, the cookbook gives you tested, copy-paste-ready patterns. Each notebook includes the full code, expected outputs, and explanations of why each approach works. The estimated token cost for a typical recipe is around 500 tokens.

The recipes also demonstrate token-efficient patterns like prompt caching, structured output formatting, and context window management -- directly applicable to reducing API costs.

§03

How to use

  1. Clone the repository:
git clone https://github.com/anthropics/anthropic-cookbook.git
cd anthropic-cookbook
pip install anthropic
  1. Browse the notebooks by topic. Each is self-contained with its own dependencies.
  1. Open any notebook in Jupyter and run the cells:
jupyter notebook misc/prompt_caching.ipynb
§04

Example

# From the tool use cookbook recipe
import anthropic

client = anthropic.Anthropic()

response = client.messages.create(
    model='claude-sonnet-4-20250514',
    max_tokens=1024,
    tools=[{
        'name': 'get_weather',
        'description': 'Get current weather for a location',
        'input_schema': {
            'type': 'object',
            'properties': {
                'location': {'type': 'string'}
            },
            'required': ['location']
        }
    }],
    messages=[{
        'role': 'user',
        'content': 'What is the weather in San Francisco?'
    }]
)
§05

Related on TokRepo

§06

Common pitfalls

  • Some notebooks require specific API features (like tool use or vision) that need the correct Claude model version. Check the model parameter in each notebook.
  • The cookbook evolves with Claude's capabilities. Older notebooks may reference deprecated parameters or model names. Always check the last-modified date.
  • Running all notebooks sequentially can incur significant API costs. Run them individually and monitor your usage dashboard.

Frequently Asked Questions

Is the Anthropic Cookbook free?+

The cookbook repository is free and open-source on GitHub. Running the notebooks requires an Anthropic API key with credits. Most recipes cost fractions of a cent per run.

What topics does the cookbook cover?+

The cookbook covers prompt engineering, tool use, retrieval-augmented generation, agents, multimodal inputs, prompt caching, structured outputs, embeddings, and enterprise patterns like content moderation and PII handling.

Can I use these recipes in production?+

Yes. The recipes demonstrate production-ready patterns. They are designed to be adapted: replace the example prompts and tools with your own and the patterns transfer directly.

How often is the cookbook updated?+

Anthropic maintains the cookbook as a living repository. New recipes are added when Claude gains new capabilities, and existing ones are updated when APIs change.

Do I need to know Python?+

Most recipes are in Python using the anthropic Python SDK. Basic Python knowledge is sufficient to follow along. A few recipes use TypeScript with the Node.js SDK.

Citations (3)
🙏

Source & Thanks

Created by Anthropic. Licensed under MIT. anthropics/anthropic-cookbook — 37,000+ GitHub stars

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.