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.
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.
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.
How to use
- Clone the repository:
git clone https://github.com/anthropics/anthropic-cookbook.git
cd anthropic-cookbook
pip install anthropic
- Browse the notebooks by topic. Each is self-contained with its own dependencies.
- Open any notebook in Jupyter and run the cells:
jupyter notebook misc/prompt_caching.ipynb
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?'
}]
)
Related on TokRepo
- AI Tools for Coding -- More AI development tools and frameworks
- Prompt Library -- Curated prompt templates for various AI tasks
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
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.
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.
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.
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.
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)
- Anthropic Cookbook GitHub— Official Anthropic cookbook with Claude API recipes
- Anthropic Tool Use Docs— Claude tool use API documentation
- Anthropic Prompt Caching Docs— Claude prompt caching for reduced API costs
Related on TokRepo
Source & Thanks
Created by Anthropic. Licensed under MIT. anthropics/anthropic-cookbook — 37,000+ GitHub stars