0PricingLogin
Learn AI with Python · Lesson

Anthropic Claude API in Python

anthropic.Anthropic(), messages.create(), content blocks, extended thinking, streaming.

The Anthropic SDK

Anthropic's Claude models are accessed through the anthropic Python package. Install with pip install anthropic. Claude excels at long-context reasoning, careful instruction following, and tool use.

pip install anthropic

import anthropic

Creating the Client

Build the client with anthropic.Anthropic(). It reads your key from the ANTHROPIC_API_KEY environment variable by default, keeping credentials out of code.

import anthropic

client = anthropic.Anthropic()

# Or explicitly
client = anthropic.Anthropic(api_key="sk-ant-...")

All lessons in this course

  1. OpenAI API: chat.completions and Streaming
  2. Anthropic Claude API in Python
  3. Function Calling and Tool Use with LLMs
  4. Prompt Engineering for Production LLM Apps
← Back to Learn AI with Python